private void OnDestroy() { _destroyed = true; foreach (GameObject ob in _objectPool.GetObjects()) { ClickBaseClass obinterface = ob.GetComponent <ClickBaseClass>(); if (obinterface) { obinterface.Clicked.RemoveAllListeners(); } } }
private void createCache() { int i = 0; while (i < _cachenumber) { GameObject go = HelperFunctions.GetPrefab2d(_prefab, gameObject, 0, 0); ClickBaseClass obinterface = go.GetComponent <ClickBaseClass>(); if (obinterface != null) { obinterface.Clicked.AddListener(ObjectClicked); } _objectPool.Add(go); i++; } }