Inheritance: MonoBehaviour
Exemplo n.º 1
0
        public void CheckAndAddHolderComponent(GameObject holder, EventHandler handler)
        {
            GPActionHolder[] holders = holder.GetComponents <GPActionHolder>();

            if (holders.Length > 1)
            {
                for (int i = 1; i < holders.Length; i++)
                {
#if UNITY_EDITOR
                    if (UnityEditor.EditorApplication.isPlaying)
                    {
                        DestroyImmediate(holders[i]);
                    }
                    else
                    {
                        DestroyImmediate(holders[i]);
                    }
#else
                    Destroy(holders[i]);
#endif
                }
            }
            else
            {
                GPActionHolder holderComponent = holder.AddComponent <GPActionHolder>();
                holderComponent._eventHandler = handler;
            }
        }