예제 #1
0
                private void OnLoadResourceAgentHelperReadFileComplete(object sender, LoadResourceAgentHelperReadFileCompleteEventArgs e)
                {
                    ResourceObject resourceObject = new ResourceObject(m_Task.ResourceInfo.ResourceName.Name, e.Resource, m_ResourceHelper);

                    m_ResourcePool.Register(resourceObject, true);
                    m_LoadingResource = false;
                    s_LoadingResourceNames.Remove(m_Task.ResourceInfo.ResourceName.Name);
                    OnResourceObjectReady(resourceObject);
                }
예제 #2
0
        private void LoadUIFormSuccessCallback(string uiFormAssetName, object uiFormAsset, float duration, object userData)
        {
            OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData;

            if (openUIFormInfo == null)
            {
                throw new System.Exception("Open UI form info is invalid.");
            }

            UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormAsset, m_UIFormHelper.InstantiateUIForm(uiFormAsset), m_UIFormHelper);

            m_InstancePool.Register(uiFormInstanceObject, true);

            m_UIFormsBeingLoaded.Remove(openUIFormInfo.SerialId);
            m_UIFormAssetNamesBeingLoaded.Remove(uiFormAssetName);
            if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId))
            {
                Log.Debug("Release UI form '{0}' on loading success.", openUIFormInfo.SerialId.ToString());
                m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId);
                m_UIFormHelper.ReleaseUIForm(uiFormAsset, null);
                return;
            }

            InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData);
        }
예제 #3
0
        private void LoadTexture2DSuccessCallback(string assetName, UnityEngine.Object asset, float duration, object userData)
        {
            AssetObject assetObject = new AssetObject(assetName, asset);

            m_AssetPool.Register(assetObject, true);

            LoadTextureInfo loadTextureInfo = (LoadTextureInfo)userData;

            if (loadTextureInfo.Target == null)
            {
                m_AssetPool.Unspawn(assetObject);
                return;
            }

            if (loadTextureInfo.Target is Image)
            {
                Image target = (Image)loadTextureInfo.Target;
                InternalSetImage(target, assetObject, loadTextureInfo.SetNativeSize);
            }
            else if (loadTextureInfo.Target is RawImage)
            {
                RawImage target = (RawImage)loadTextureInfo.Target;
                InternalSetRawImage(target, assetObject, loadTextureInfo.SetNativeSize);
            }
            //todo
        }
예제 #4
0
        private void LoadUIFormSuccessCallback(string uiFormAssetName, object uiFormAsset, float duration, object userData)
        {
            OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData;

            if (openUIFormInfo == null)
            {
                throw new GameFrameworkException("Open UI form info is invalid.");
            }

            if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId))
            {
                m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId);
                ReferencePool.Release(openUIFormInfo);
                m_UIFormHelper.ReleaseUIForm(uiFormAsset, null);
                return;
            }

            m_UIFormsBeingLoaded.Remove(openUIFormInfo.SerialId);
            UIFormInstanceObject uiFormInstanceObject = UIFormInstanceObject.Create(uiFormAssetName, uiFormAsset, m_UIFormHelper.InstantiateUIForm(uiFormAsset), m_UIFormHelper);

            m_InstancePool.Register(uiFormInstanceObject, true);

            InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData);
            ReferencePool.Release(openUIFormInfo);
        }
예제 #5
0
        /// <summary>
        /// 打开界面。
        /// </summary>
        /// <param name="uiFormAssetName">界面资源名称。</param>
        /// <param name="uiGroupName">界面组名称。</param>
        /// <param name="uiGroupDepth">界面组深度</param>
        /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void OpenUIForm(string uiFormAssetName, string uiGroupName, int uiGroupDepth, bool pauseCoveredUIForm, object userData)
        {
            Guard.Verify <ArgumentException>(m_UIFormHelper == null, "You must set UI form helper first.");
            Guard.NotEmptyOrNull(uiFormAssetName, "UI form asset name is invalid.");
            Guard.NotEmptyOrNull(uiGroupName, "UI group name is invalid.");

            UIGroup uiGroup = (UIGroup)GetUIGroup(uiGroupName);

            if (uiGroup == null)
            {
                uiGroup = (UIGroup)AddUIGroup(uiGroupName, uiGroupDepth);
            }

            if (HasUIForm(uiFormAssetName))
            {
                return;
            }

            UIFormInstanceObject uiFormInstanceObject = m_InstancePool.Spawn(uiFormAssetName);

            if (uiFormInstanceObject == null)
            {
                // 把资源加载抽到这里,为后续异步加载资源与实例化分开处理
                var uiFormInstance = m_UIFormHelper.InstantiateUIForm(ResourceUtils.Load(uiFormAssetName));
                uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormInstance, m_UIFormHelper);
                m_InstancePool.Register(uiFormInstanceObject, true);

                InnerOpenUIForm(uiFormAssetName, uiGroup, uiFormInstanceObject.Target, pauseCoveredUIForm, true, userData);
            }
            else
            {
                InnerOpenUIForm(uiFormAssetName, uiGroup, uiFormInstanceObject.Target, pauseCoveredUIForm, false, userData);
            }
        }
예제 #6
0
파일: BulletHelper.cs 프로젝트: zhoulk/Lufy
    public Bullet Spawn()
    {
        Bullet bullet = m_BulletPool.Spawn();

        if (bullet == null)
        {
            string     name = "bullet" + m_serial++;
            GameObject obj  = GameObject.Instantiate(m_prefab);
            obj.name = name;
            bullet   = Bullet.Create(bulletAssetName, obj);
            m_BulletPool.Register(bullet, true);
        }
        return(bullet);
    }
예제 #7
0
        private void InstantiateUIFormSuccessCallback(string uiFormAssetName, object uiFormInstance, float duration, object userData)
        {
            UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormInstance, m_UIFormHelper);

            m_InstancePool.Register(uiFormInstanceObject, true);

            OpenUIFormInfo openUIFormInfo = userData as OpenUIFormInfo;

            if (openUIFormInfo == null)
            {
                throw new GameFrameworkException("Open UI form info is invalid.");
            }

            InternalOpenUIForm(openUIFormInfo.UIFormTypeId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData);
        }
예제 #8
0
        private IntentItem CreateIntentItem(Entity entity)
        {
            IntentItem       intentItem       = null;
            IntentItemObject intentItemObject = m_IntentObjectPool.Spawn();

            if (intentItemObject != null)
            {
                intentItem = (IntentItem)intentItemObject.Target;
            }
            else
            {
                intentItem = Instantiate(m_IntentItemTemplate, m_WidgetInstanceRoot, false);
                m_IntentObjectPool.Register(IntentItemObject.Create(intentItem), true);
            }
            return(intentItem);
        }
예제 #9
0
        private FlightPathItem CreateFlightPathItem()
        {
            FlightPathItem   pathItem         = null;
            FlightPathObject flightPathObject = _FlightPathObjectPool.Spawn();

            if (flightPathObject != null)
            {
                pathItem = (FlightPathItem)flightPathObject.Target;
            }
            else
            {
                pathItem = Instantiate(_FlightPathItemTemplate);
                _FlightPathObjectPool.Register(new FlightPathObject(pathItem), true);
            }

            return(pathItem);
        }
예제 #10
0
        private void LoadControllerSuccessCallback(string assetName, UnityEngine.Object asset, float duration, object userData)
        {
            AssetObject assetObject = new AssetObject(assetName, asset);

            m_AssetPool.Register(assetObject, true);

            LoadControllerInfo loadControllerInfo = (LoadControllerInfo)userData;

            if (loadControllerInfo.TargetAnimator == null)
            {
                m_AssetPool.Unspawn(assetObject);
                return;
            }
            InternalSetController(loadControllerInfo.TargetAnimator, assetObject);

            //todo
        }
예제 #11
0
        void LoadAssetSuccess(string assetName, object asset, float duration, object userData)
        {
            GameObject obj = GameObject.Instantiate(asset as GameObject);

            obj.name = obj.name.Substring(0, obj.name.Length - 7);
            obj.transform.SetParent(m_InstanceRoot);
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            UIFormLogic uiFormInstanceObject = obj.GetComponent <UIFormLogic>();

            m_cachedForms.Add(assetName, uiFormInstanceObject);
            m_InstancePool.Register(UIFormObject.Create(assetName, uiFormInstanceObject, asset), true);

            uiFormInstanceObject.OnInit(userData);

            InternalOpenUIForm(assetName, uiFormInstanceObject, duration, userData);
        }
예제 #12
0
        private HPBarItem CreateHPBarItem(Entity entity)
        {
            HPBarItem       hpBarItem;
            HPBarItemObject hpBarItemObject = m_HPBarItemObjectPool.Spawn();

            if (hpBarItemObject != null)
            {
                hpBarItem = (HPBarItem)hpBarItemObject.Target;
            }
            else
            {
                hpBarItem = Instantiate(m_HPBarItemTemplate, m_WidgetInstanceRoot, false);
                m_HPBarItemObjectPool.Register(HPBarItemObject.Create(hpBarItem), true);
            }

            return(hpBarItem);
        }
예제 #13
0
        private void LoadAvtarSuccessCallback(string assetName, UnityEngine.Object asset, float duration, object userData)
        {
            AssetObject assetObject = new AssetObject(assetName, asset);

            m_AssetPool.Register(assetObject, true);

            LoadAvtarInfo loadAvtarInfo = (LoadAvtarInfo)userData;

            if (loadAvtarInfo.AvtarInfo.Owner == null || !loadAvtarInfo.AvtarInfo.Owner.IsAvailable)
            {
                m_AssetPool.Unspawn(assetObject);
                return;
            }
            InternalAddSkinnedMesh(loadAvtarInfo.AvtarInfo, assetObject);

            //todo
        }
예제 #14
0
        /// <summary>
        /// 根据名称获取实例化的GameObject
        /// </summary>
        /// <param name="name">GameObject的名称</param>
        /// <returns>实例化的GameObject</returns>
        public GameObject Spawn(string name)
        {
            GameObject gameObject = null;

            InstanceGameObject instanceGameObject = m_InstanceGameObjectPool.Spawn(name);

            if (instanceGameObject != null)
            {
                gameObject = (GameObject)instanceGameObject.Target;
            }
            else
            {
                gameObject = UnityEngine.Object.Instantiate(m_GameobjectAsset);
                m_InstanceGameObjectPool.Register(new InstanceGameObject(name, gameObject), true);
            }
            return(gameObject);
        }
예제 #15
0
                private void OnLoadResourceAgentHelperLoadComplete(object sender, LoadResourceAgentHelperLoadCompleteEventArgs e)
                {
                    AssetObject assetObject = null;

                    if (m_Task.IsScene)
                    {
                        assetObject = m_AssetPool.Spawn(m_Task.AssetName);
                    }

                    if (assetObject == null)
                    {
                        assetObject = new AssetObject(m_Task.AssetName, e.Asset, m_Task.GetDependencyAssets(), m_Task.Resource, m_AssetPool, m_ResourcePool, m_ResourceHelper);
                        m_AssetPool.Register(assetObject, true);
                    }

                    m_LoadingAsset = false;
                    s_LoadingAssetNames.Remove(m_Task.AssetName);
                    OnAssetObjectReady(assetObject);
                }
예제 #16
0
        private void LoadUIFormSuccessCallback(string uiFormAssetName, object uiFormAsset, float duration, object userData)
        {
            OpenUIForm openUIFormInfo = (OpenUIFormInfo)userData;

            m_UIFormBeingLoaded.Remove(openUIFormInfo.SerialId);
            m_UIFormAssetNamesBeingLoaded.Remove(uiFormAssetName);
            if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId))
            {
                Log.Debug();
                m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId);
                m_UIFormHelper.ReleaseUIForm(uiFormAsset, null);
                return;
            }

            UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormAsset, m_UIFormHelper.InstantiateUIForm(uiFormAsset), m_UiFormHelper);
            m_InstancePool.Register(uiFormInstanceObject, true);

            InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, uiFormInstanceObject.Target);
        }
예제 #17
0
        private HPBarItem CreateHPBarItem(Entity entity)
        {
            HPBarItem       hpBarItem       = null;
            HPBarItemObject hpBarItemObject = m_HPBarItemObjectPool.Spawn();

            if (hpBarItemObject != null)
            {
                hpBarItem = (HPBarItem)hpBarItemObject.Target;
            }
            else
            {
                hpBarItem = Instantiate(m_HPBarItemTemplate);
                Transform transform = hpBarItem.GetComponent <Transform>();
                transform.SetParent(m_HPBarInstanceRoot);
                transform.localScale = Vector3.one;
                m_HPBarItemObjectPool.Register(HPBarItemObject.Create(hpBarItem), true);
            }

            return(hpBarItem);
        }
예제 #18
0
        private DisplayItem CreateDisplayItem(Entity entity)
        {
            DisplayItem       displayItem       = null;
            DisplayItemObject displayItemObject = m_DisplayItemObjectPool.Spawn();

            if (displayItemObject != null)
            {
                displayItem = (DisplayItem)displayItemObject.Target;
            }
            else
            {
                displayItem = Instantiate(m_DisplayItemTemplate);
                Transform transform = displayItem.GetComponent <Transform>();
                transform.SetParent(m_DisplayInstanceRoot);
                transform.localScale = Vector3.one;
                m_DisplayItemObjectPool.Register(DisplayItemObject.Create(displayItem), true);
            }

            return(displayItem);
        }
예제 #19
0
        private ExpBarItem CreateExpBarItem(Entity entity)
        {
            ExpBarItem       expBarItem       = null;
            ExpBarItemObject expBarItemObject = m_ExpBarItemObjectPool.Spawn();

            if (expBarItemObject != null)
            {
                expBarItem = (ExpBarItem)expBarItemObject.Target;
            }
            else
            {
                expBarItem = Instantiate(m_ExpBarItemTemplate);
                Transform transform = expBarItem.GetComponent <Transform>();
                transform.SetParent(m_ExpBarInstanceRoot);
                transform.localScale = Vector3.one;
                m_ExpBarItemObjectPool.Register(ExpBarItemObject.Create(expBarItem), true);
            }

            return(expBarItem);
        }
예제 #20
0
    protected override void OnOpen(object userData)
    {
        base.OnOpen(userData);
        button = GetComponentInChildren <Button>();
        text   = GetComponentInChildren <Text>();
        RectTransform buttonRT = button.GetComponent <RectTransform>();
        RectTransform textRT   = text.GetComponent <RectTransform>();

        buttonRT.SetPositionX(0);
        buttonRT.SetPositionY(Screen.height - 0);
        buttonRT.sizeDelta      = new Vector2(Screen.width / 2, Screen.height / 2);
        textRT.anchoredPosition = buttonRT.anchoredPosition + new Vector2(buttonRT.sizeDelta.x / 2, -buttonRT.sizeDelta.y / 2);
        textRT.sizeDelta        = new Vector2(Screen.width / 4, Screen.height / 4);
        text.fontSize           = 20;
        button.onClick.AddListener(OnStarButtonClick);

        testPool = GameEntry.ObjectPool.CreateMultiSpawnObjectPool <TestObject>();
        TestObject obj = new TestObject(prefab, "poolOBJ");

        testPool.Register(obj, false);
    }
예제 #21
0
        /// <summary>
        /// 创建定时器
        /// </summary>
        /// <returns></returns>
        public TimeAction CreateTimeAction()
        {
            TimeAction timeAction = null;

            TimeActionObject timeActionObject = m_TimeActionObjectPool.Spawn();

            if (timeActionObject != null)
            {
                timeAction = (TimeAction)timeActionObject.Target;
            }
            else
            {
                timeAction = new TimeAction();
                TimeActionObject actionObject = new TimeActionObject();
                actionObject.Initialize(timeAction);
                m_TimeActionObjectPool.Register(actionObject, true);
            }
            timeAction.Reset();

            return(timeAction);
        }
        //创建实体血条
        private HPBarItem CreateHPbarItem()
        {
            HPBarItem hpBarItem;
            //先从对象池获取
            HPBarItemObject hpBarItemObject = m_HPBarItemObjectPool.Spawn();

            if (hpBarItemObject != null)
            {
                hpBarItem = hpBarItemObject.Target as HPBarItem;
            }
            else
            {
                //对象池中不存在,则创建新的
                ReferenceCollector referenceCollector = Object.Instantiate(m_HPBarItemTemplate).GetComponent(typeof(ReferenceCollector)) as ReferenceCollector;
                hpBarItem = new HPBarItem(referenceCollector);

                referenceCollector.CachedTransform.SetParent(m_HPBarInstanceRoot, false);
                m_HPBarItemObjectPool.Register(new HPBarItemObject(hpBarItem), true);
            }

            return(hpBarItem);
        }
예제 #23
0
        /// <summary>
        /// Spawn 对象
        /// </summary>
        /// <param name="objAssetName">资源名称 带路径名 </param>
        /// <returns></returns>
        public async Task <UnityEngine.GameObject> Spawn(string objAssetName)
        {
            UnityEngine.GameObject target       = null;
            NormalObject           normalObject = m_InstancePool.Spawn(objAssetName);

            if (normalObject == null)
            {
                //UnityEngine.GameObject objAsset = ResourceManager.Instance.LoadAssetDataPath<UnityEngine.GameObject>(objAssetName);
                UnityEngine.GameObject objAsset = await GameFrameEntry.GetModule <AssetbundleModule>().LoadPrefab(objAssetName);

                if (objAsset != null)
                {
                    normalObject = new NormalObject(objAssetName, null, objAsset, m_UnspawnParent);
                    m_InstancePool.Register(normalObject, true);
                }
            }
            if (normalObject != null)
            {
                target = normalObject.Target as UnityEngine.GameObject;
            }
            return(target);
        }
예제 #24
0
        private void Start()
        {
            m_ObjectPoolComponent = GameBox.GetComponent <ObjectPoolComponent>();
            m_IObjectPoo01        = m_ObjectPoolComponent.CreateSingleSpawnObjectPool <OPDemo>("对象池01");
            m_IObjectPoo02        = m_ObjectPoolComponent.CreateSingleSpawnObjectPool <OPDemo>("对象池02", 10, 1);

            m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false);
            m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false);
            m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false);
            m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false);
            m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false);
            m_IObjectPoo01.Register(new OPDemo("对象池01_对象1", GameObject.CreatePrimitive(PrimitiveType.Cube)), false);


            m_IObjectPoo02.Register(new OPDemo("对象池02_对象2", m_Target), false);

            m_Target = GameObject.Instantiate(m_Target);
            m_Target.Register <OPDemo>("对象池03_对象1", "对象1");
            m_Target = GameObject.Instantiate(m_Target);
            m_Target.Register <OPDemo>("对象池03_对象1", "对象1");

            gameObject.Register <OPDemo>("对象池04_对象1", "对象1");
        }
                private void OnLoadResourceAgentHelperLoadComplete(object sender, LoadResourceAgentHelperLoadCompleteEventArgs e)
                {
                    AssetObject assetObject = null;

                    if (m_Task.IsScene)
                    {
                        assetObject = m_AssetPool.Spawn(m_Task.AssetName);
                    }

                    if (assetObject == null)
                    {
                        assetObject = new AssetObject(m_Task.AssetName, e.Asset, m_Task.GetDependencyAssets(), m_Task.ResourceObject.Target, m_AssetPool, m_ResourcePool, m_ResourceHelper, m_ResourceLoader.m_AssetDependencyCount);
                        m_AssetPool.Register(assetObject, true);
                        foreach (object dependencyResource in m_Task.GetDependencyResources())
                        {
                            m_Task.ResourceObject.AddDependencyResource(dependencyResource);
                        }
                    }

                    m_LoadingAsset = false;
                    s_LoadingAssetNames.Remove(m_Task.AssetName);
                    OnAssetObjectReady(assetObject);
                }
예제 #26
0
파일: UIManager.cs 프로젝트: 542767059/ABC
        private void LoadUIFormSuccessCallback(string uiFormAssetName, UnityEngine.Object uiFormAsset, float duration, object userData)
        {
            OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData;

            if (openUIFormInfo == null)
            {
                throw new Exception("Open UI form info is invalid.");
            }

            m_UIFormsBeingLoaded.Remove(openUIFormInfo.SerialId);
            if (m_UIFormsToReleaseOnLoad.Contains(openUIFormInfo.SerialId))
            {
                m_UIFormsToReleaseOnLoad.Remove(openUIFormInfo.SerialId);
                GameEntry.Resource.UnloadAsset(uiFormAsset);
                return;
            }

            UIFormInstanceObject uiFormInstanceObject = new UIFormInstanceObject(uiFormAssetName, uiFormAsset, UnityEngine.Object.Instantiate(uiFormAsset));

            m_InstancePool.Register(uiFormInstanceObject, true);

            InternalOpenUIForm(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup, uiFormInstanceObject.Target, openUIFormInfo.PauseCoveredUIForm, true, duration, openUIFormInfo.UserData);
        }
 public void RegisterEntityInstanceObject(EntityInstanceObject obj, bool spawned)
 {
     m_InstancePool.Register(obj, spawned);
 }
예제 #28
0
            public object LoadAssetSync(string assetName, IResourceHelper resourceHelper)
            {
                ResourceInfo?resourceInfo = null;

                string[] dependencyAssetNames          = null;
                string[] scatteredDependencyAssetNames = null;
                string   resourceChildName             = null;

                if (!CheckAsset(assetName, out resourceInfo, out dependencyAssetNames, out scatteredDependencyAssetNames, out resourceChildName))
                {
                    string errorMessage = string.Format("Can not load asset '{0}'.", assetName);
                    Log.Warning(errorMessage);
                    return(null);
                }

                if (resourceInfo == null)
                {
                    string errorMessage = string.Format("Can no checkAsset :", assetName);
                    throw new GameFrameworkException(errorMessage);
                }

                AssetObject assetObject = m_AssetPool.Spawn(assetName);

                if (assetObject != null)
                {
                    return(assetObject.Target);
                }

                object[] dependencyAssets = new object[dependencyAssetNames.Length];
                for (int i = 0; i < dependencyAssetNames.Length; i++)
                {
                    object asset = LoadDependencyAssetSync(dependencyAssetNames[i], resourceHelper);
                    if (asset != null)
                    {
                        dependencyAssets[i] = asset;
                    }
                    else
                    {
                        string errorMessage = string.Format(
                            "Can not load dependency asset '{0}' when load asset '{1}'.", dependencyAssetNames[i],
                            assetName);
                        throw new GameFrameworkException(errorMessage);
                    }
                }

                ResourceObject resourceObject = m_ResourcePool.Spawn(resourceInfo.Value.ResourceName.Name);

                if (resourceObject != null)
                {
                    object      asset    = m_SyncLoadResourceHelper.LoadAssetSync(resourceObject.Target, resourceChildName);
                    AssetObject assetObj = new AssetObject(assetName, asset, dependencyAssets, resourceObject.Target,
                                                           m_AssetPool, m_ResourcePool, resourceHelper);
                    m_AssetPool.Register(assetObj, true);
                    return(asset);
                }

                string fullPath =
                    Utility.Path.GetCombinePath(
                        resourceInfo.Value.StorageInReadOnly ? m_ReadOnlyPath : m_ReadWritePath,
                        Utility.Path.GetResourceNameWithSuffix(resourceInfo.Value.ResourceName.FullName));
                object resourceObj = null;

                if (resourceInfo.Value.LoadType == LoadType.LoadFromFile)
                {
                    resourceObj = m_SyncLoadResourceHelper.ReadFileSync(fullPath);
                }
                else
                {
                    byte[] bytes = m_SyncLoadResourceHelper.ReadBytesSync(fullPath, (int)resourceInfo.Value.LoadType);
                    resourceObj = m_SyncLoadResourceHelper.ParseBytesSync(bytes);
                }

                if (resourceObj != null)
                {
                    ResourceObject resObject = new ResourceObject(resourceInfo.Value.ResourceName.Name, resourceObj,
                                                                  resourceHelper);
                    m_ResourcePool.Register(resObject, true);

                    object      asset    = m_SyncLoadResourceHelper.LoadAssetSync(resObject.Target, resourceChildName);
                    AssetObject assetObj = new AssetObject(assetName, asset, dependencyAssets, resObject.Target, m_AssetPool, m_ResourcePool, resourceHelper);
                    m_AssetPool.Register(assetObj, true);
                    return(asset);
                }
                else
                {
                    string errorMessage = string.Format("Can not load asset '{0}' when load asset '{1}'.", assetName);
                    throw new GameFrameworkException(errorMessage);
                }
            }
 public void RegisterItemInstanceObject(ItemInstanceObject obj, bool spawned)
 {
     m_InstancePool.Register(obj, spawned);
 }