private void OnDestroy() { Button button = this.gameObject.GetComponent <Button> (); if (button == null) // Button may already be destroyed { return; } button.onClick.RemoveAllListeners(); this.emptyStringContainer = null; }
private void Start() { this.stringText = this.gameObject.GetComponentInChildren <Text> (); if (this.stringText == null) { Debug.LogError("[Player] Missing Text"); return; } Button button = this.gameObject.GetComponent <Button> (); button.onClick.AddListener(ChangeState); this.emptyStringContainer = new EmptyStringContainer(); this.stringText.text = this.emptyStringContainer.SetState(0); }