Beispiel #1
0
        /// <summary>
        /// 异步加载资源的话,都会有Asset
        /// </summary>
        /// <param name="name">Name.</param>

        public void LoadAsync(string filename, System.Action <UObj, string> finished)
        {
            Utils.Assert(string.IsNullOrEmpty(filename), "Can't Load Empty Resource");
                        #if Package
            CoroutineProvider.Instance().StartCoroutine(AsyncAb(filename, finished));
                        #else
            CoroutineProvider.Instance().StartCoroutine(Async(filename, finished));
                        #endif
        }
Beispiel #2
0
        public void LoadAsync(string filename, Action <UObj, string> finished)
        {
            Utils.Assert(string.IsNullOrEmpty(filename), "Can't Load Empty Resource");

            ///
            /// 有一定策略来决定是Resource加载还是Assetbundle加载
            ///
                        #if Package
            CoroutineProvider.Instance().StartCoroutine(AsyncAb(filename, finished));
                        #else
            CoroutineProvider.Instance().StartCoroutine(AsyncRes(filename, finished));
                        #endif
        }
Beispiel #3
0
        private void LoadEnd()
        {
            if (cachedWork.Count > 0)
            {
                AssetTask task = cachedWork.Dequeue();

                if (task != null)
                {
                    if (dicLoadingReq.Count < MAX_WWW_COUNT)
                    {
                        // 如果没下载,则开始下载
                        CoroutineProvider.Instance().StartCoroutine(AsyncLoadCoroutine(task));
                    }
                    else
                    {
                        cachedWork.Enqueue(task);
                    }
                }
            }
        }
        static void Initialize()
        {
            if (!initialized)
            {
                if (!Application.isPlaying)
                {
                    return;
                }
                initialized = true;
                var g = new GameObject("Corountine Provider");

                var gobal = GameObject.FindGameObjectWithTag("Global");
                if (gobal != null)
                {
                    g.transform.parent = gobal.transform;
                }
                _current = g.AddComponent <CoroutineProvider>();
                DontDestroyOnLoad(g);
            }
        }
Beispiel #5
0
        // name表示 不包含路径的预设体名,
        public void LoadAsync(AssetTask task)
        {
            if (task == null)
            {
                return;
            }
            // 如果已经下载,则返回
            if (dicAsset.ContainsKey(task.AssetBundleName))
            {
                return;
            }

            // 如果正在下载,则返回
            if (dicLoadingReq.ContainsKey(task.AssetBundleName))
            {
                return;
            }

            if (dicLoadingReq.Count < MAX_WWW_COUNT)
            {
                if (Core.DevFSM.rtPlatform == RuntimePlatform.OSXEditor || Core.DevFSM.rtPlatform == RuntimePlatform.OSXPlayer)
                {
                    //CoroutineProvider.Instance().StartCoroutine(AsyncLoadLoacl(task));
                    CoroutineProvider.Instance().StartCoroutine(AsyncLoadCoroutine(task));
                }
                else
                {
                    // 如果没下载,则开始下载
                    CoroutineProvider.Instance().StartCoroutine(AsyncLoadCoroutine(task));
                }
            }
            else
            {
                cachedWork.Enqueue(task);
            }
        }
 void Awake()
 {
     _current    = this;
     initialized = true;
 }