Example #1
0
        internal void GetScene(string name, Action callBack, LoadPriority priority = LoadPriority.Default, bool isAdditive = false)
        {
            mIsAdditive = isAdditive;

            string bundleName = this.ResourceMgr.GetBundleName(name);

            if (string.IsNullOrEmpty(bundleName))
            {
                bundleName = this.ResourceMgr.GetBundleName(name + ".unity");
            }
            if (bundleName == string.Empty)
            {
                Debug.LogError("can not find scene: " + name);
                return;
            }
            bool isCached = ResourceMgr.IsBundleCached(bundleName);

            if (/*GOERootCore.IsEditor ||*/ HasLoaded(name) || isCached)
            {
                if (mCurScene.ToLower() != name.ToLower())
                {
                    if (isCached)
                    {
                        var bundle = ResourceMgr.AssetBundleGroup.CacheManager.Cache[bundleName];
                        bundle.IsSceneBundle = true;//Set to active scene bundle
                        bundle.Touch();
                    }
                    LoadScene(name);
                    if (callBack != null)
                    {
                        callBack();
                    }
                    return;
                }
                else
                {
                    removeBundle(name);
                }
            }

            mCurScene        = name;
            getSceneCallback = callBack;

            ResourceMgr.AssetBundleGroup.PreloadBundle(bundleName, OnLoadAssetBundle, LoadPriority.MostPrior, true);

            /*Resource res = this.GetDownloadResource(bundleName);
             * if (res == null)
             * {
             *  res = this.CreateResource(bundleName, priority);
             *  res.LoadRes();
             * }
             *
             * //逻辑加载时,提高优先级//
             * if (res.Loader.Priority < priority)
             * {
             *  this.ResourceMgr.GOELoaderMgr.SetLoaderPriority(res.Loader, priority);
             * }
             * res.AddGotSceneCallback(callBack);*/
        }