Esempio n. 1
0
        /// <summary>
        /// 主线程回调
        /// </summary>
        /// <param name="ev"></param>
        private static void MainRunAction(object ev)
        {
            TheardEvent cache = (TheardEvent)ev;

            try
            {
                if (cache.action == null)
                {
                    DebugMod.Log("theard action is null" + cache.name);
                }
                cache.action();
            }
            catch
            {
                DebugMod.LogError("run thunder cathch" + cache.name);
            }
            finally
            {
                if (cache.callback != null)
                {
                    cache.callback();
                }
                Interlocked.Decrement(ref m_iRunThreadsNum);
            }
        }
Esempio n. 2
0
        public static T Load <T>(string path) where T : Object
        {
            if (!Instance.mCacheDic.ContainsKey(path))
            {
                T res = Resources.Load <T>(path);
                if (res == null)
                {
                    DebugMod.LogError("can't find res from " + path);
                    return(null);
                }
                Instance.mCacheDic[path] = new ResCache()
                {
                    resCache = (Object)res
                };
            }

            return(Instance.mCacheDic[path].resCache as T);
        }
Esempio n. 3
0
        IEnumerator LoadSceneEnumerator(string path, string scenename, VoidDelegate loadfinishdo)
        {
            if (string.IsNullOrEmpty(scenename))
            {
                yield break;
            }

            _www = new WWW(path);
            yield return(_www);

            _sceneBundle = _www.assetBundle;
            _www.Dispose();
            _www = null;

            if (_sceneBundle != null)
            {
                _asyn = Application.LoadLevelAsync(scenename);
                yield return(_asyn);

                if (_asyn.isDone)
                {
                    yield return(1);

                    try
                    {
                        if (loadfinishdo != null)
                        {
                            loadfinishdo();
                        }
                    }
                    catch
                    {
                        DebugMod.LogError("Error occored in LoadSceneEnumerator callback delegate");
                    }


                    _asyn = null;
                }
            }
            else
            {
                DebugMod.LogError("can't load scene from: " + path);
            }
        }
Esempio n. 4
0
        public static void Trigger <T>(T e) where T : EventArgs
        {
            Delegate del;

            if (Instance.mEventDic.TryGetValue(typeof(T), out del))
            {
                EventDelegate <T> callback = del as EventDelegate <T>;
                try
                {
                    if (callback != null)
                    {
                        callback(e);
                    }
                }
                catch
                {
                    DebugMod.LogError("Event Trigger error on:" + typeof(T).ToString());
                }
            }
        }
Esempio n. 5
0
        public AssetBundle LoadAsset(string path)
        {
            AssetBundle ab = null;

            if (mAssetBundleDic.ContainsKey(path))
            {
                ab = GetAssetBundle(path);
            }
            else
            {
                ab = LoadAssetMemory(path);
                AddAssetBundle(path, ab);
                if (ab == null)
                {
                    DebugMod.LogError("can't get AssetBundle null from " + path);
                }
                //GameMain.Instance.StartCoroutine(LoadBundleEnumerator(path, cb, managercharge));
            }
            return(ab);
        }
Esempio n. 6
0
        /// <summary>
        /// 加载Asset资源
        /// </summary>
        /// <param name="path">StreamingAssets下相对路径</param>
        /// <param name="sourcename">资源名</param>
        /// <param name="cb">回调函数</param>
        /// <returns></returns>
        public Object LoadAsset(string path, string sourcename)
        {
            Object      obj = null;
            AssetBundle ab  = GetAssetBundle(path);

            if (ab != null)
            {
                obj = ab.LoadAsset(sourcename);
            }
            else
            {
                ab = LoadAssetMemory(path);
                AddAssetBundle(path, ab);
                obj = ab.LoadAsset(sourcename);

                if (obj == null)
                {
                    DebugMod.LogError("can't get assetresource object null from " + path);
                }
            }
            return(obj);
        }