Demo entry 6660482

1

   

Submitted by anonymous on Nov 15, 2017 at 15:26
Language: Java. Code size: 2.0 kB.

using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;



public class Gamemanager : MonoBehaviour{

	public Button start;
	public Button setting;
	public Button settingbutton;
	public Button help;
	public Button weapon;

	public Image st_image;
	//public Image se_image;
	public Image he_image;
	public Image we_image;
	
	private int state = 0;
	// Use this for initialization
	void Start () {
		
		start.onClick.AddListener(On_startBtnDown);
		setting.onClick.AddListener(On_settingBtnDown);
		settingbutton.onClick.AddListener(On_settingImageBtnDown);
		help.onClick.AddListener(On_helpBtnDown);
		weapon.onClick.AddListener(On_weaponBtnDown);

		settingbutton.gameObject.SetActive(false);
		//se_image.gameObject.SetActive(false);
		he_image.gameObject.SetActive(false);
		we_image.gameObject.SetActive(false);
	}

	void On_startBtnDown() {
		state = 1;
		SceneManager.LoadScene("test1");
		
	}
	void On_settingBtnDown() {
		he_image.gameObject.SetActive(false);
		settingbutton.gameObject.SetActive(true);
	}

	void On_settingImageBtnDown() {

		settingbutton.gameObject.SetActive(false);
	}

	void On_helpBtnDown() {
		state = 3;
		settingbutton.gameObject.SetActive(false);
		he_image.gameObject.SetActive(true);
	}
	void On_weaponBtnDown(){
		state = 4;
		settingbutton.gameObject.SetActive(false);
		we_image.gameObject.SetActive(true);
	}

	// Update is called once per frame
	void Update () {
		

		if (Input.GetMouseButtonDown(0))
		{
			
			switch (state)
			{
				case 0:
					break;
				case 1:
					
					break;
				case 2:       
					break;
				case 3:
					state = 0;
					he_image.gameObject.SetActive(false);
					break;
				case 4:
					state = 2;
					we_image.gameObject.SetActive(false);
					settingbutton.gameObject.SetActive(true);
					break;
			 
			}
		}
		
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).