public static bool GetEntityFromSource(System.Type tp, object obj, out SPEntity entity)
        {
            if (tp == null)
            {
                throw new System.ArgumentNullException("tp");
            }
            entity = null;
            var go = GameObjectUtil.GetTrueRootFromSource(obj);

            if (go == null)
            {
                return(false);
            }

            SPEntity e;

            if (_pool.TryGetValue(go, out e) && TypeUtil.IsType(e.GetType(), tp))
            {
                entity = e;
                return(true);
            }
            else if (TypeUtil.IsType(tp, typeof(SPEntity)))
            {
                entity = go.GetComponent(tp) as SPEntity;
                return(entity != null);
            }

            return(false);
        }
Пример #2
0
 public SPEntity GetEntity()
 {
     if (!_synced)
     {
         _synced = true;
         _entity = this.GetComponentInParent <SPEntity>();
     }
     return(_entity);
 }
        protected void SyncRoot()
        {
            _synced = true;
            _entity = SPEntity.Pool.GetFromSource(this);
#if SP_LIB
            _entityRoot = (_entity != null) ? _entity.gameObject : this.FindRoot();
#else
            _entityRoot = (_entity != null) ? _entity.transform : this.gameObject;
#endif
        }
Пример #4
0
 private void OnDisable()
 {
     if (_synced)
     {
         _synced = false;
         if (_entity != null && !this.transform.IsChildOf(_entity.transform))
         {
             _entity = null;
         }
     }
 }
        public static bool GetEntityFromSource(object obj, out SPEntity entity)
        {
            entity = null;
            var go = GameObjectUtil.GetTrueRootFromSource(obj);

            if (go == null)
            {
                return(false);
            }

            SPEntity e;

            if (_pool.TryGetValue(go, out e))
            {
                entity = e;
                return(true);
            }
            else
            {
                entity = go.GetComponent <SPEntity>();
                return(entity != null);
            }
        }
Пример #6
0
 protected void SyncRoot()
 {
     _synced     = true;
     _entity     = SPEntity.Pool.GetFromSource(this);
     _entityRoot = (_entity != null) ? _entity.gameObject : this.gameObject;
 }
Пример #7
0
 protected virtual void OnTransformParentChanged()
 {
     _synced     = false;
     _entity     = null;
     _entityRoot = null;
 }
Пример #8
0
 public static bool GetEntityFromSource(System.Type tp, object obj, out SPEntity entity)
 {
     return(SPEntity.Pool.GetFromSource(tp, obj, out entity));
 }
Пример #9
0
 public static bool GetEntityFromSource(object obj, out SPEntity entity)
 {
     return(SPEntity.Pool.GetFromSource(obj, out entity));
 }
Пример #10
0
 public static SPEntity GetEntityFromSource(object obj)
 {
     return(SPEntity.GetEntityFromSource(obj));
 }
Пример #11
0
 public static bool GetEntityFromSource <T>(object obj, out T entity) where T : SPEntity
 {
     return(SPEntity.GetEntityFromSource <T>(obj, out entity));
 }
Пример #12
0
 private void OnTransformParentChanged()
 {
     _synced = false;
     _entity = null;
 }