Beispiel #1
0
 /// <summary>
 /// 获取上的实体对象
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dataModel"></param>
 /// <returns></returns>
 public T GetEntity <T>(DataModelBehaviour dataModel) where T : BaseDataModelEntity
 {
     if (dataModel.DataEntity is T)
     {
         return((T)dataModel.DataEntity);
     }
     return(null);
 }
Beispiel #2
0
        /// <summary>
        /// 获取一个GameObject上的实体对象
        /// </summary>
        /// <typeparam id="T"></typeparam>
        /// <param id="go"></param>
        /// <returns></returns>
        public T GetEntity <T>(GameObject go) where T : BaseDataModelEntity
        {
            T entity = null;
            DataModelBehaviour dm = go.GetComponent <DataModelBehaviour>();

            if (dm != null)
            {
                entity = (T)dm.DataEntity;
            }
            return(entity);
        }