Пример #1
0
        private IEnumerator OnLoadSceneAsync(string sceneName, bool additive)
        {
            progress = 0;
            isDone   = false;
            // var loadSceneMode = additive ? UnityEngine.SceneManagement.LoadSceneMode.Additive : UnityEngine.SceneManagement.LoadSceneMode.Single;
            // var async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
            var async = AssetsManger.LoadSceneAsync(sceneName, additive);

            _loading.Add(sceneName, async);
            while (!async.isDone)
            {
                if (async.progress >= 0.9f)
                {
                    Progress(1.0f);
                }
                else
                {
                    Progress(async.progress);
                }

                yield return(null);
            }
            _loaded.Add(sceneName, async);
            Completed(sceneName);
        }
Пример #2
0
        internal override void Load()
        {
            bundleRequest = AssetsManger.LoadBundle(assetBundleName);
            var assetName = Path.GetFileName(url);

            asset = bundleRequest.assetBundle.LoadAsset(assetName, assetType);
        }
Пример #3
0
        private static byte[] CustomLoader(ref string filepath)
        {
            string scriptPath = string.Empty;

            filepath = filepath.Replace(".", "/");

            if (!GameUtility.Assets.runtimeMode)
            {
                scriptPath = Utility.Path.Combine(GameConst.LUA_SCRIPTS_PATH, filepath) + ".lua";;

                return(Utility.Files.ReadAllBytes(scriptPath));
            }

            scriptPath = GameUtility.Assets.GetAssetPath(AssetBundles.Lua, filepath) + GameConst.LUA_EXTENSION;
            var request = AssetsManger.LoadAsset(scriptPath, typeof(TextAsset));

            if (!string.IsNullOrEmpty(request.error))
            {
                Log.Error(request.error);
                return(null);
            }
            request.Release();
            var text = (request.asset as TextAsset).text;

            return(System.Text.Encoding.UTF8.GetBytes(text));
        }
Пример #4
0
 internal override void Load()
 {
     if (!string.IsNullOrEmpty(assetBundleName))
     {
         bundleRequest = AssetsManger.LoadBundle(assetBundleName);
         if (bundleRequest != null)
         {
             SceneManager.LoadScene(sceneName, loadSceneMode);
         }
     }
     else
     {
         try
         {
             SceneManager.LoadScene(sceneName, loadSceneMode);
             loadState = LoadState.LoadAsset;
         }
         catch (Exception e)
         {
             Log.Error(e);
             error     = e.ToString();
             loadState = LoadState.Loaded;
         }
     }
 }
Пример #5
0
 public SceneAssetRequest(string path, bool additive)
 {
     base.url = path;
     AssetsManger.GetAssetBundleName(path, out assetBundleName);
     sceneName     = Path.GetFileNameWithoutExtension(base.url);
     loadSceneMode = additive ? LoadSceneMode.Additive : LoadSceneMode.Single;
 }
Пример #6
0
        public void Init(string path)
        {
            TextAsset request = (TextAsset)AssetsManger.LoadAsset(path, typeof(TextAsset)).asset;

            string[] words = request.text.Split(new string[1] {
                "\r\n"
            }, StringSplitOptions.None);
            for (int i = 0; i < words.Length; ++i)
            {
                string singleWord = words[i];
                if (singleWord.Length > 0)
                {
                    Dictionary <string, Node> next   = null;
                    Dictionary <string, Node> nowDic = dic;
                    if (!nowDic.ContainsKey(singleWord[0].ToString()))
                    {
                        Node rootNode = new Node();
                        rootNode.depth = 1;
                        nowDic.Add(singleWord[0].ToString(), rootNode);
                        next = rootNode.next;
                    }
                    else
                    {
                        next = nowDic[singleWord[0].ToString()].next;
                    }

                    Node nextNode = null;
                    for (int j = 1; j < singleWord.Length; ++j)
                    {
                        if (next == null)
                        {
                            next           = new Dictionary <string, Node>();
                            nextNode       = new Node();
                            nextNode.depth = j + 1;
                            next.Add(singleWord[j].ToString(), nextNode);
                            nowDic[singleWord[j - 1].ToString()].next = next;
                        }
                        else
                        {
                            if (!next.ContainsKey(singleWord[j].ToString()))
                            {
                                nextNode       = new Node();
                                nextNode.depth = j + 1;
                                next.Add(singleWord[j].ToString(), nextNode);
                            }
                            else
                            {
                                nextNode = next[singleWord[j].ToString()];
                            }
                        }
                        nowDic = next;
                        next   = nextNode.next;
                    }
                }
            }
            //PrintNode("", dic);
        }
Пример #7
0
        /// <summary>
        /// 低内存时的处理逻辑
        /// </summary>
        protected virtual void OnLowMemory()
        {
            Log.Warning("Low memory reported...");
            // TODO:释放对象池
            // TODO:释放加载的资源
            AssetsManger.Clear();

            Resources.UnloadUnusedAssets();
            System.GC.Collect();
        }
Пример #8
0
 internal override void Load()
 {
     if (!string.IsNullOrEmpty(assetBundleName))
     {
         bundleRequest = AssetsManger.LoadBundleAsync(assetBundleName);
         loadState     = LoadState.LoadAssetBundle;
     }
     else
     {
         LoadSceneAsync();
     }
 }
Пример #9
0
 internal override void Load()
 {
     _assetName = Path.GetFileNameWithoutExtension(url);
     if (GameUtility.Assets.runtimeMode)
     {
         _request           = AssetsManger.LoadBundle(_assetName.ToLower(), true);
         _request.completed = Request_completed;
         loadState          = LoadState.LoadAssetBundle;
     }
     else
     {
         loadState = LoadState.Loaded;
     }
 }
Пример #10
0
        public void OnClear()
        {
            OnMessage("数据清除完毕");
            OnProgress(0);

            Reset();

            _downloader.Clear();
            _status         = UStatus.Idle;
            _netWorkChanged = false;

            AssetsManger.Clear();

            listener?.OnClear();

            Versions.Clear();
        }
Пример #11
0
        /// <summary>
        /// 加载多语言配置
        /// </summary>
        /// <param name="completed"></param>
        public static void Load(System.Action completed = null)
        {
            if (string.IsNullOrEmpty(_lanCode))
            {
                _lanCode = Language.current;
            }
            // var request = Resources.LoadAsync<TextAsset>("lc_cn_ERROR");
            // request.completed += (async) =>
            // {
            //     TextAsset textAsset = request.asset as TextAsset;
            //     Parse(textAsset.text);
            //     if (completed != null) completed();
            // };
            var path    = "Assets/AssetBundles/Localization/lc_zh_LOGIN.json";
            var request = AssetsManger.LoadAssetAsync(path, typeof(TextAsset));

            request.completed = (re) =>
            {
                if (string.IsNullOrEmpty(request.error))
                {
                    TextAsset textAsset = re.asset as TextAsset;
                    Parse(textAsset.text);
                }
                else
                {
                    Log.Error(string.Format("Load Localization error:{0}", request.error));
                }
                re.Release();
                if (completed != null)
                {
                    completed();
                }
                if (OnLocalize != null)
                {
                    OnLocalize.Invoke();
                }
            };
        }
Пример #12
0
 private void Request_completed(AssetRequest req)
 {
     _request.completed = null;
     if (_request.assetBundle == null)
     {
         error = "assetBundle == null";
     }
     else
     {
         var manifest = _request.assetBundle.LoadAsset <BundleManifest>(_assetName);
         if (manifest == null)
         {
             error = "manifest == null";
         }
         else
         {
             AssetsManger.OnLoadManifest(manifest);
             _request.assetBundle.Unload(true);
             _request.assetBundle = null;
         }
     }
     loadState = LoadState.Loaded;
 }
Пример #13
0
 public void Load()
 {
     request = AssetsManger.LoadSceneAsync(url, isAdditive);
 }
Пример #14
0
 public void Load()
 {
     request = AssetsManger.LoadAssetAsync(url, type);
 }
Пример #15
0
 public void Load()
 {
     request            = AssetsManger.LoadAssetAsync(url, typeof(GameObject));
     request.completed += OnAssetLoaded;
 }
Пример #16
0
 internal override void Load()
 {
     bundleRequest = AssetsManger.LoadBundleAsync(assetBundleName);
     loadState     = LoadState.LoadAssetBundle;
 }