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); }
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 }
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); } }
protected void SyncRoot() { _synced = true; _entity = SPEntity.Pool.GetFromSource(this); _entityRoot = (_entity != null) ? _entity.gameObject : this.gameObject; }
protected virtual void OnTransformParentChanged() { _synced = false; _entity = null; _entityRoot = null; }
public static bool GetEntityFromSource(System.Type tp, object obj, out SPEntity entity) { return(SPEntity.Pool.GetFromSource(tp, obj, out entity)); }
public static bool GetEntityFromSource(object obj, out SPEntity entity) { return(SPEntity.Pool.GetFromSource(obj, out entity)); }
public static SPEntity GetEntityFromSource(object obj) { return(SPEntity.GetEntityFromSource(obj)); }
public static bool GetEntityFromSource <T>(object obj, out T entity) where T : SPEntity { return(SPEntity.GetEntityFromSource <T>(obj, out entity)); }
private void OnTransformParentChanged() { _synced = false; _entity = null; }