public void destroy() { for (int i = 0; i < _characters.Length; i++) { ClickDetector clicker = _characters[i].GetComponent<ClickDetector>() as ClickDetector; clicker.dispatcher.RemoveListener(ClickDetector.CLICK, onCharacterClick); } // TODO destroy everything }
internal void init(string nameText, string[] portraitPaths, string[] clanNames, string[] descriptions) { _portraits = new Sprite[portraitPaths.Length]; for (int i = 0; i< portraitPaths.Length; i++) { _portraits[i] = Resources.Load<Sprite>(portraitPaths[i]); } _clanNames = clanNames; _descriptions = descriptions; SetCanvasText("Canvas/NameText", nameText); SetClanSelected(0); _characters = new GameObject[portraitPaths.Length]; for (int i = 0; i < portraitPaths.Length; i++) { _characters[i] = GameObject.Find("Canvas/ClanImage" + (i+1)); _characters[i].AddComponent<ClickDetector>(); ClickDetector clicker = _characters[i].GetComponent<ClickDetector>() as ClickDetector; clicker.dispatcher.AddListener(ClickDetector.CLICK, onCharacterClick); } }