/// <summary>
        /// 显示实体。
        /// </summary>
        /// <param name="entityId">实体编号</param>
        /// <param name="entityLogicType">实体逻辑类型</param>
        /// <param name="entityAssetName">实体资源名称</param>
        /// <param name="entityGroupName">实体组名称</param>
        /// <param name="userData">用户自定义数据</param>
        public void ShowEntity(int entityId, Type entityLogicType, string entityAssetName, string entityGroupName, object userData)
        {
            if (entityLogicType == null)
            {
                Debug.LogError("显示实体时的实体逻辑类型为空");
                return;
            }
            ShowEntityInfo info = new ShowEntityInfo(entityLogicType, userData);

            if (m_ResourceManager == null)
            {
                Debug.LogError("显示实体时的资源管理器为空");
                return;
            }

            if (m_EntityHelper == null)
            {
                Debug.LogError("显示实体时的辅助器为空");
                return;
            }

            if (string.IsNullOrEmpty(entityAssetName))
            {
                Debug.LogError("显示实体时的实体资源名称为空");
                return;
            }

            if (string.IsNullOrEmpty(entityGroupName))
            {
                Debug.LogError("显示实体时的实体组名称为空");
                return;
            }

            if (m_EntityInfos.ContainsKey(entityId))
            {
                Debug.LogError("显示实体时的实体信息已存在");
                return;
            }

            if (IsLoadingEntity(entityId))
            {
                Debug.LogError("要显示的实体已在加载");
                return;
            }

            //实体组检查
            EntityGroup entityGroup = GetEntityGroup(entityGroupName);

            if (entityGroup == null)
            {
                Debug.LogError("显示实体时的实体组不存在");
                return;
            }

            //尝试从对象池获取实体实例
            EntityInstanceObject entityInstanceObject = entityGroup.SpawnEntityInstanceObject(entityAssetName);

            if (entityInstanceObject == null)
            {
                //没获取到就加载该实体
                int serialId = m_Serial++;
                m_EntitiesBeingLoaded.Add(entityId, serialId);
                m_ResourceManager.LoadAsset(entityAssetName, m_LoadAssetCallbacks, new LoadEntityInfo(serialId, entityId, entityGroup, info));
                return;
            }

            ShowEntity(entityId, entityAssetName, entityGroup, entityInstanceObject.Target, false, 0f, info);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 实体显示
        /// </summary>
        /// <param name="userData">用户自定义数据</param>
        public void OnShow(object userData)
        {
            ShowEntityInfo showEntityInfo = (ShowEntityInfo)userData;

            Logic.OnShow(showEntityInfo.UserData);
        }