Ejemplo n.º 1
0
        void Initialize()
        {
            Pools.Clear();
            IPool[] goPools = GetComponents <IPool>();
            foreach (IPool p in goPools)
            {
                if (p is ComponentPool)
                {
                    if (Pools.ContainsKey(p.Identifier) == false)
                    {
                        Pools.Add(p.Identifier, p);
                    }
                    else
                    {
                        DTLog.Log("[DevTools] Found a duplicated ComponentPool for type " + p.Identifier + ". The duplicated pool will be destroyed");
#if UNITY_EDITOR
                        if (!Application.isPlaying)
                        {
                            DestroyImmediate(p as ComponentPool);
                        }
                        else
#endif
                        Destroy(p as ComponentPool);
                    }
                }
                else
                {
                    p.Identifier = GetUniqueIdentifier(p.Identifier);
                    Pools.Add(p.Identifier, p);
                }
            }

            IsInitialized = true;
        }
Ejemplo n.º 2
0
        private void sendBeforePush(Component item)
        {
            GameObject itemGameObject = item.gameObject;

            if (itemGameObject.activeSelf && itemGameObject.activeInHierarchy)
            {
                //Send message works only for active game objects. Source: https://docs.unity3d.com/ScriptReference/GameObject.SendMessage.html
                itemGameObject.SendMessage("OnBeforePush", SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                if (item is IPoolable)
                {
                    ((IPoolable)item).OnBeforePush();
                }
                else
                {
                    DTLog.LogWarning("[Curvy] sendBeforePush could not send message because the receiver " + item.name + " is not active");
                }
            }
        }