Example #1
0
    IEnumerator StartInit(Action onStart, Action <int> progress)
    {
        onStart();
        StartCoroutine(NoticeManager.Instance.DownloadNotice());
        progress(10);
        yield return(null);

        if (gameObject.GetComponent <LoadResources>() == null)
        {
            gameObject.AddComponent(SystemSwitch.ReleaseMode ? typeof(LoadAssetBundlesMainAsset) : typeof(LoadResources));
        }
        if (SystemSwitch.ReleaseMode)
        {
            ResourceManager.LoadMetaOfMeta(
                () =>
            {
                List <string> shaders = new List <string>();
                if (Directory.Exists(Path.Combine(SystemConfig.ResourceFolder, "Resources/Shader")))
                {
                    shaders = FileAccessManager.GetFileNamesByDirectory("Resources/Shader");
                    shaders = (from s in shaders
                               let r = System.IO.Path.GetFileName(s).ReplaceFirst(SystemConfig.ASSET_FILE_EXTENSION, String.Empty)
                                       where r.EndsWith(".shader", StringComparison.CurrentCultureIgnoreCase)
                                       select r).ToList();
                }
                else
                {
                    shaders = ResourceIndexInfo.Instance.GetFileNamesByDirectory("Resources/Shader");
                    shaders = (from s in shaders
                               let r = Mogo.Util.Utils.GetStreamPath(s)
                                       where r.EndsWith(".shader", StringComparison.CurrentCultureIgnoreCase)
                                       select r).ToList();
                }

                AssetCacheMgr.GetResources(shaders.ToArray(), null);

                StartCoroutine(AfterInit(progress));
            },
                (index, total) =>
            {
                if (total == 0)
                {
                    return;
                }
                var proc = ((40 - 10) * index / total) + 10;
                Driver.Invoke(() => { progress(proc); });
            }
                );
        }
        else
        {
            StartCoroutine(AfterInit(progress));
        }
    }