Example #1
0
        internal void GetAsset(string name, Action <string, UnityEngine.Object> callback, LoadPriority priority = LoadPriority.Default)
        {
            if (name == null || name == string.Empty)
            {
                return;
            }
            if (HasLoaded(name))
            {
                if (callback != null)
                {
                    GetAssetInCache(name, callback);
                }
                return;
            }
#if UNITY_EDITOR
            UnityEngine.Object obj = LoadFromPrefab(name, typeof(UnityEngine.Object));
            if (obj != null)
            {
                SetAsset(name, obj).Reference = 1;
                if (callback != null)
                {
                    callback(name, GOEAsset.InstanceAsset(obj, name));
                }
                return;
            }
#endif
            string bundleName = ResourceMgr.GetBundleName(name);
            if (bundleName == string.Empty)
            {
                Logger.GetFile(LogFile.Res).LogError("can not find asset: " + name);
                return;
            }
            if (!cacheMgr.HasLoadingInfo(bundleName))
            {
                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);
                }
            }
            cacheMgr.AddCallbackToDic(name, callback);
        }
Example #2
0
        internal void EnsureDependencies(string name)
        {
            string bundleName = ResourceMgr.GetBundleName(name);

            if (!string.IsNullOrEmpty(bundleName))
            {
                GOEBundle bundle = ResourceMgr.GetBundle(bundleName);
                if (bundle != null)
                {
                    foreach (var dep in bundle.DependsOn)
                    {
                        GOEBundle depBundle = ResourceMgr.GetBundle(dep);
                        if (depBundle == null)
                        {
                            continue;
                        }
                        if (!HasLoaded(depBundle.FirstAsset))
                        {
                            GOERoot.ResMgr.PreloadBundle(dep, null);
                        }
                    }
                }
            }
        }
Example #3
0
 public string GetBundleName(string assetname)
 {
     return(resourceMgr.GetBundleName(assetname));
 }