using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class ToggleMenus : MonoBehaviour { //Menus public GameObject rotMenu; public GameObject colorMenu; public GameObject shapesMenu; public GameObject lightingMenu; public GameObject expMenu; private bool ActiveMenu = false; //Shapes - Prefabs public GameObject player; public GameObject Cube; public GameObject Sphere; public GameObject Cylinder; public GameObject Capsule; public GameObject Temp; public GameObject mySpawn; //Use with lighting menu //private GameObject lighting = GameObject.FindGameObjectWithTag("Lighting"); public float lightRotX, lightRotY, lightRotZ; private string Spawn = "Spawn"; private string Active = "Cube"; // Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); mySpawn = GameObject.Find("PlayerSpawn"); InitializeButtonArrays(); Temp = Cube; lightRotX = 0; lightRotY = 0; lightRotZ = 0; //EditLightingRotation(); //EditLightingLocation(); } public void Update() { GameObject.FindGameObjectWithTag("Lighting").transform.Rotate(lightRotX, lightRotY, lightRotZ); } public void ToggleRotationMenu() { if (rotMenu.gameObject.activeSelf) { rotMenu.gameObject.SetActive(false); ActiveMenu = !ActiveMenu; } else if (!rotMenu.gameObject.activeSelf && ActiveMenu) { CloseAll(); rotMenu.gameObject.SetActive(true); } else { rotMenu.gameObject.SetActive(true); ActiveMenu = !ActiveMenu; } } public void ToggleColorMenu() { if (colorMenu.activeSelf) { colorMenu.gameObject.SetActive(false); ActiveMenu = !ActiveMenu; } else if (!colorMenu.activeSelf && ActiveMenu) { CloseAll(); colorMenu.SetActive(true); } else { colorMenu.SetActive(true); ActiveMenu = !ActiveMenu; } } public void ToggleShapesMenu() { if (shapesMenu.gameObject.activeSelf) { shapesMenu.gameObject.SetActive(false); ActiveMenu = !ActiveMenu; } else if (!shapesMenu.gameObject.activeSelf && ActiveMenu) { CloseAll(); shapesMenu.gameObject.SetActive(true); } else { shapesMenu.gameObject.SetActive(true); ActiveMenu = !ActiveMenu; } } public void ToggleLightingMenu() { if (lightingMenu.gameObject.activeSelf) { lightingMenu.gameObject.SetActive(false); ActiveMenu = !ActiveMenu; } else if (!lightingMenu.gameObject.activeSelf && ActiveMenu) { CloseAll(); lightingMenu.gameObject.SetActive(true); } else { lightingMenu.gameObject.SetActive(true); ActiveMenu = !ActiveMenu; } } public void ToggleExpMenu() { if (expMenu.gameObject.activeSelf) { expMenu.gameObject.SetActive(false); //check if another menu is open to avoid overlapping ActiveMenu = !ActiveMenu; } else if (!expMenu.gameObject.activeSelf && ActiveMenu) { CloseAll(); expMenu.gameObject.SetActive(true); } else { expMenu.gameObject.SetActive(true); ActiveMenu = !ActiveMenu; } } public void CloseAll() { shapesMenu.gameObject.SetActive(false); rotMenu.gameObject.SetActive(false); colorMenu.gameObject.SetActive(false); lightingMenu.gameObject.SetActive(false); expMenu.gameObject.SetActive(false); } public void ChangeShape(string shape) { switch (shape) { case "Cube": Instantiate(Cube, mySpawn.transform.position, mySpawn.transform.rotation); Debug.Log("Destroy " + Active); Destroy(GameObject.Find(Active)); Active = "Cube(Clone)"; player = GameObject.FindGameObjectWithTag("Player"); Debug.Log(Active); break; case "Sphere": Instantiate(Sphere, mySpawn.transform.position, mySpawn.transform.rotation); Debug.Log("Destroy " + Active); Destroy(GameObject.Find(Active)); Active = "Sphere(Clone)"; player = GameObject.FindGameObjectWithTag("Player"); Debug.Log(Active); break; case "Capsule": Instantiate(Capsule, mySpawn.transform.position, mySpawn.transform.rotation); Debug.Log("Destroy " + Active); Destroy(GameObject.Find(Active)); Active = "Capsule(Clone)"; player = GameObject.FindGameObjectWithTag("Player"); Debug.Log(Active); break; case "Cylinder": Instantiate(Cylinder, mySpawn.transform.position, mySpawn.transform.rotation); Debug.Log("Destroy " + Active); Destroy(GameObject.Find(Active)); Active = "Cylinder(Clone)"; player = GameObject.FindGameObjectWithTag("Player"); Debug.Log(Active); break; default: Debug.Log("Error - Not a valid shape : " + shape); break; } } /* public void EditLightingRotation() { buttons = GameObject.FindGameObjectsWithTag("RotationMenuButtons"); foreach (Object button in buttons) { gameObject.GetComponent