示例#1
0
        private IEnumerator <object> WaitForAll_Coroutine()
        {
            TaskCount = CreateInstances.Count;
            foreach (IEnumerator <object> enumerator in CreateInstances)
            {
                ILRuntimeService.StartILCoroutine(enumerator);
            }

            while (TaskCount > 0)
            {
                yield return(null);
            }
            TaskCount = StartInstance.Count;
            foreach (IEnumerator <object> enumerator in StartInstance)
            {
                ILRuntimeService.StartILCoroutine(enumerator);
            }
            while (TaskCount > 0)
            {
                yield return(null);
            }

            TaskCount = Windows.Count;
            foreach (Type window in Windows)
            {
                AssetBundlePool.LoadAsset <GameObject>(
                    "bmpfont_prefab.assetbundle",
                    window.Name,
                    (gameObject) =>
                {
                    GameSystemData.Instance.PrefabCache.Insert(new PrefabAsset(window.Name, gameObject));
                    TaskCount--;
                });
            }
            while (TaskCount > 0)
            {
                yield return(null);
            }

            GameSystemData.Instance.FontSettingWindow = FontSettingWindow.OpenWindow();
            GameSystemData.Instance.MenuWindow        = MenuWindow.OpenWindow();
            GameSystemData.Instance.RendererWindow    = RendererWindow.OpenWindow();
            Debug.Log("return GameStart.WaitForAll_Coroutine.");
        }
        private void UpdatePendingRequests()
        {
            if (_lockCount <= 0 && _pendingRequests.Count > 0)
            {
                var pendingIt = _pendingRequests.First;
                while (pendingIt != null)
                {
                    if (_loadingRequestCount > _maxLoadingAssetNum)
                    {
                        break;
                    }

                    var req  = pendingIt.Value;
                    var next = pendingIt.Next;

                    var assetInfo = req.AssetInfo;
                    if (IsPendingReuqest(req))
                    {
                        pendingIt = next;
                        //waiting for previous identical assets loaded.
                        continue;
                    }

                    if (req.IsDisposed)
                    {
                        _loadedRequests.Enqueue(req);
                    }
                    else
                    {
                        switch (req.RequestType)
                        {
                        case ELoadRequestType.Bundle:
                        {
                            try
                            {
                                _bundleLoadProfile.BeginProfileOnlyEnableProfile();
                                _bundlePool.LoadAssetBundle(req.AssetInfo.BundleName);
                            }
                            finally
                            {
                                _bundleLoadProfile.EndProfileOnlyEnableProfile();
                            }

                            break;
                        }

                        case ELoadRequestType.Scene:
                        {
                            try
                            {
                                _sceneLoadProfile.BeginProfileOnlyEnableProfile();
                                _bundlePool.LoadScene(assetInfo.BundleName, assetInfo.AssetName,
                                                      req.IsAdditiveScene);
                                _loadingScenes.Add(assetInfo);
                                _loadedRequests.Enqueue(req);
                                req.IsDisposed = true;
                            }
                            finally
                            {
                                _sceneLoadProfile.EndProfileOnlyEnableProfile();
                            }

                            break;
                        }

                        case ELoadRequestType.Asset:
                        {
                            try
                            {
                                _assetLoadProfile.BeginProfileOnlyEnableProfile();

                                if (TryLoadFromAssetPool(req))
                                {
                                    _loadedRequests.Enqueue(req);
                                }
                                else
                                {
                                    _bundlePool.LoadAsset(assetInfo.BundleName, assetInfo.AssetName,
                                                          req.Option.ObjectType);
                                    var node = AssetLoadRequestNode.Alloc(req);
                                    AssetLoadRequestNode cachedNode;
                                    if (_loadingRequests.TryGetValue(req.AssetInfo, out cachedNode))
                                    {
                                        node.Next       = cachedNode.Next;
                                        cachedNode.Next = node;
                                    }
                                    else
                                    {
                                        _loadingRequests[req.AssetInfo] = node;
                                    }

                                    _loadingRequestCount++;
                                }
                            }
                            finally
                            {
                                _assetLoadProfile.EndProfileOnlyEnableProfile();
                            }

                            break;
                        }
                        }
                    }

                    _pendingRequests.Remove(pendingIt);
                    pendingIt = next;
                }
            }
        }
示例#3
0
 public static void LoadAsset_GameObject(string assetBundleName, string name, Action <GameObject> callback) =>
 AssetBundlePool.LoadAsset(assetBundleName, name, callback);
示例#4
0
 public static void LoadAsset_Material(string assetBundleName, string name, Action <Material> callback) =>
 AssetBundlePool.LoadAsset(assetBundleName, name, callback);
示例#5
0
 public static void LoadAsset_Sprite(string assetBundleName, string name, Action <Sprite> callback) =>
 AssetBundlePool.LoadAsset(assetBundleName, name, callback);
示例#6
0
 public static void LoadAsset_TextAsset(string assetBundleName, string name, Action <TextAsset> callback) =>
 AssetBundlePool.LoadAsset(assetBundleName, name, callback);