private void Awake() { // Sanity checks Assert.IsNotNull(this.UIToolboxPanelPrefab); // Initialise internal state this.name = "UIToolboxContainer"; this.Panels = new List <UIToolboxPanel>(); // Load toolbox configuration from JSON TextAsset toolboxConfigAsset = Resources.Load <TextAsset>(TOOLBOX_CONFIG_RESOURCE); Assert.IsNotNull(toolboxConfigAsset); UIToolboxConfig toolboxConfig = JsonUtility.FromJson <UIToolboxConfig>(toolboxConfigAsset.text); // Instantiate and build sub panels foreach (var subpanelConfig in toolboxConfig.panels) { UIToolboxPanel panel = Instantiate(this.UIToolboxPanelPrefab, this.transform); Assert.IsNotNull(panel); panel.Build(subpanelConfig); this.Panels.Add(panel); } // Instantiate and build main panel Assert.IsNull(this.MainPanel); UIToolboxPanel mainPanel = Instantiate(this.UIToolboxPanelPrefab, this.transform); Assert.IsNotNull(mainPanel); mainPanel.Build(toolboxConfig); this.Panels.Add(mainPanel); // Finalise toolbox this.CurrentPanel = this.MainPanel; }
protected void Start() { this.ToolboxPanel = this.GetComponentInParent <UIToolboxPanel>(); this.gameObject.GetComponent <Image>().sprite = this.InactiveSprite; Assert.IsNotNull(this.ToolboxPanel); InfoPanel = FindObjectOfType <UIOverlayInfoPanel>(); Assert.IsNotNull(InfoPanel); }
/// <summary> /// Assume referenced panel has been built at this stage /// </summary> protected new void Start() { base.Start(); // There's probably a better way to do this UIToolboxContainer toolboxContainer = GameObject.FindObjectOfType <UIToolboxContainer>(); Assert.IsNotNull(toolboxContainer); string referencedName = UIToolboxPanel.NAME_PREFIX + this.SimpleName; this.ReferencedPanel = toolboxContainer.Panels.Find(p => p.name == referencedName); Assert.IsNotNull(this.ReferencedPanel); }