private void Awake()
        {
            // Check if we have an entity component here, or else create it and give feedback to the manager.
            if (!GetComponent <WrapperEudiEntity>())
            {
                Eudi.EntitiesManager._addEntity(gameObject); // add the entity component.
            }
            else
            {
                var wrapper = GetComponent <WrapperEudiEntity>();
                if (!wrapper.IsOnRightGameObject())
                {
                    wrapper.ThrowFakeException_DifferentGameObject();
                    DestroyImmediate(wrapper); //< We use DestroyImmediate because we need to delete it right now, not after the frame.

                    //Add new wrapper...
                    Eudi.EntitiesManager._addEntity(gameObject);
                }
            }

            EudiEntity   = GetComponent <WrapperEudiEntity>().Instance;
            EudiEntityId = EudiEntity.Id;

            InternalAwake();
        }
Beispiel #2
0
        private void Awake()
        {
            if (Instance == null)
            {
                _currentGameObjectId = gameObject.GetInstanceID();
                Instance             = new EudiEntity(this);
            }
            else
            {
                Debug.Log(IsOnRightGameObject());

                Instance = null;

                DestroyImmediate(this); //< We use DestroyImmediate because we need to delete it right now, not after the frame.

                ThrowFakeException_DifferentGameObject();
            }
        }
Beispiel #3
0
        private void OnDestroy()
        {
            // We can't allow the total destruction of an entity caused by copying a gameObject.
            if (!IsOnRightGameObject())
            {
                Instance = null;
                return;
            }

            Eudi.EntitiesManager._removeEntity(gameObject);

            Instance.Wrapper = null;

            Instance.Components.Clear();
            Instance.Components = null;

            Instance.EudiComponents.Clear();
            Instance.EudiComponents = null;

            Instance.SharedModules.Clear();
            Instance.SharedModules = null;

            Instance = null;
        }