Exemplo n.º 1
0
        /// <summary>
        /// 加载实体成功回调
        /// </summary>
        /// <param name="entityAssetName">实体资源名称</param>
        /// <param name="entityAsset">实体资源</param>
        /// <param name="duration">加载时间</param>
        /// <param name="userData">用户数据</param>
        private void LoadEntitySuccessCallback(string entityAssetName, UnityEngine.Object entityAsset, float duration, object userData)
        {
            ShowEntityInfo showEntityInfo = (ShowEntityInfo)userData;

            if (showEntityInfo == null)
            {
                throw new Exception("Show entity info is invalid.");
            }

            m_EntitiesBeingLoaded.Remove(showEntityInfo.EntityId);
            if (m_EntitiesToReleaseOnLoad.Contains(showEntityInfo.SerialId))
            {
                Log.Info("Release entity '{0}' (serial id '{1}') on loading success.", showEntityInfo.EntityId.ToString(), showEntityInfo.SerialId.ToString());
                m_EntitiesToReleaseOnLoad.Remove(showEntityInfo.SerialId);
                GameEntry.Resource.UnloadAsset(entityAsset);
                return;
            }

            EntityInstanceObject entityInstanceObject = new EntityInstanceObject(entityAssetName, entityAsset, UnityEngine.Object.Instantiate(entityAsset));

            showEntityInfo.EntityGroup.RegisterEntityInstanceObject(entityInstanceObject, true);

            InternalShowEntity(showEntityInfo.EntityId, entityAssetName, showEntityInfo.EntityGroup, entityInstanceObject.Target, true, duration, showEntityInfo.EntityLogicType, showEntityInfo.UserData);
        }