コード例 #1
0
        // redundant code with RegisteredComponentEx !!

        protected virtual void Awake()
        {
            if ( !isRegistered )
            {
                RegisteredComponentController._Register( this );
                isRegistered = true;
                isUnregistered = false;
            }
            else
                Debug.LogWarning( "RegisteredComponent: Awake() not correctly called. Object: " + name );
        }
コード例 #2
0
        protected virtual void OnDestroy()
        {
            if ( isRegistered && !isUnregistered )
            {
                RegisteredComponentController._Unregister( this );
                isRegistered = false;
                isUnregistered = true;
            }
            else
            {
                bool alreadyUnregisteredProperly = !isRegistered && isUnregistered;

                if ( !alreadyUnregisteredProperly ) // for poolable objects OnDestroy() can get called multiple times
                {
                    Debug.LogWarning( "RegisteredComponent: OnDestroy() not correctly called. Object: " + name + " isRegistered:" + isRegistered + " isUnregistered:" + isUnregistered );
                }
            }
        }