// changes the currently active GUI public void ChangeCurrentGUI(string name) { for (int i = 0; i < GUIs.Length; i++) { if (GUIs[i].name == name) { currentGUI.Deactivate(); currentGUI = GUIs[i]; currentGUI.ship = ship; currentGUI.pim = this; currentGUI.Activate(); return; } } Debug.LogError("Invalid name \"" + name + "\" specified for ChangeCurrentGUI"); }
public override void Load() { base.Load(); //modify our mana cap IL.Terraria.Player.Update += PlayerManaUpdate; //makes sure UI isn't opened server side if (!Main.dedServ) { gui = new GUI(); gui.Activate(); guiInterface = new UserInterface(); guiInterface.SetState(gui); levelUI = new SpendUI(); levelUI.Activate(); levelInterface = new UserInterface(); levelInterface.SetState(levelUI); } }
// Use this for initialization void Start() { ship = GameObject.FindGameObjectWithTag("Ship").GetComponent <ShipManager>(); if (ship == null) { Debug.LogError("Ship object could not be found!"); } GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); if (canvas == null) { Debug.LogError("Canvas object could not be found!"); } // get all components, including the inactive ones GUIs = canvas.GetComponentsInChildren <GUI>(true); if (GUIs.Length == 0) { Debug.LogError("Could not find any GUIs!"); } currentGUI = GUIs[0]; if (NetworkClient.active) { // register the event handlers ship.EventTest += HandleTestEvent; ship.pim = this; } Debug.Log("Setting GUI's ship value"); currentGUI.ship = ship; currentGUI.pim = this; currentGUI.Activate(); Debug.Log("Done setting GUI's ship value"); }