public void Awake() { this.camera = FindObjectOfType<CameraController>(); this.eventSystem = FindObjectOfType<EventSystem>(); this.font = (font == null) ? Resources.GetBuiltinResource<Font>("Arial.ttf") : font; this.labels = GetComponentsInChildren<Text>(); this.menus = GetComponentsInChildren<Canvas>().Select(c => c.gameObject).ToArray(); GetComponentsInChildren<Selectable>().ToList().ForEach(s => s.colors = colors); foreach (Text label in labels) { label.font = font; label.text = label.text.Localize(); } if (eventSystem == null) { eventSystem = new GameObject("Event System", typeof(EventSystem)).GetComponent<EventSystem>(); } }
public void Awake() { this.camera = Camera.main.gameObject.GetComponent<CameraController>(); this.chapters = GetComponentsInChildren<Canvas>().Select(c => c.gameObject).ToArray(); this.eventSystem = FindObjectOfType<EventSystem>(); this.menu = FindObjectOfType<MenuController>(); this.mounts = chapters.Select(c => c.transform.FindChild("Mounting Point").gameObject).ToArray(); // Enable Menu, Intro & Tower 1 PlayerPrefs.SetInt("bIsLevelAvailable0", 1); PlayerPrefs.SetInt("bIsLevelAvailable1", 1); PlayerPrefs.SetInt("bIsLevelAvailable2", 1); if (Debug.isDebugBuild) { // Enable all towers when in editor PlayerPrefs.SetInt("bIsLevelAvailable3", 1); PlayerPrefs.SetInt("bIsLevelAvailable4", 1); PlayerPrefs.SetInt("bIsLevelAvailable5", 1); PlayerPrefs.SetInt("bIsLevelAvailable6", 1); } int levelIndex = 1; foreach (Button button in GetComponentsInChildren<Button>()) { // Assign functions to each button in the menu if (PlayerPrefs.GetInt("bIsLevelAvailable" + levelIndex, 0) > 0) { button.interactable = true; } else { button.interactable = false; } if (levelIndex == 1) { levelIndex++; } levelIndex++; } }