コード例 #1
0
        private void LoadAtlas(string atlasRes, Action cb = null)
        {
            string assetPath = ResObjUtil.GetObjPath(atlasRes);

            BundleMgr.Instance.GetAsset(assetPath, (objs, cbId) =>
            {
                UObj[] assets = (UObj[])objs;
                foreach (var asset in assets)
                {
                    Sprite sprite = asset as Sprite;
                    if (null != sprite)
                    {
                        if (cache.ContainsKey(sprite.name))
                        {
                            this.Msg($"atlas {atlasRes} sprite {sprite.name} already added");
                        }
                        else
                        {
                            cache.Add(sprite.name, sprite);
                        }
                    }
                }
                if (null != cb)
                {
                    cb();
                }
            });
        }
コード例 #2
0
 public T LoadSync(string res)
 {
     this.res  = res;
     assetCbId = 0;
     assetPath = ResObjUtil.GetObjPath(res);
     asset     = BundleMgr.Instance.GetAssetSync(assetPath) as T;
     return(asset);
 }
コード例 #3
0
 public void LoadSync(string res)
 {
     this.res  = res;
     assetCbId = 0;
     assetPath = ResObjUtil.GetObjPath(res);
     UObj[] objs = (UObj[])BundleMgr.Instance.GetAssetSync(assetPath);
     foreach (var o in objs)
     {
         T tAsset = o as T;
         if (null != tAsset)
         {
             ProcessEachAsset(tAsset);
         }
     }
 }
コード例 #4
0
 public void Load(string res, Action onLoad)
 {
     this.res  = res;
     assetPath = ResObjUtil.GetObjPath(res);
     if (null == assetPath)
     {
         if (null != onLoad)
         {
             onLoad();
         }
     }
 #if UNITY_EDITOR
     if (!AppEnv.UseBundleInEditor)
     {
         LoadAssetAtEditor(onLoad);
         return;
     }
 #endif
     LoadAsync(onLoad);
 }
コード例 #5
0
        private void LoadShader(string shaderAsset, Action cb = null)
        {
            string assetPath = ResObjUtil.GetObjPath(shaderAsset);

            if (null != assetPath)
            {
                BundleMgr.Instance.GetAsset(assetPath, (assets, cbId) =>
                {
                    //暂时注释掉,现在会影响加载速度,预计替换为ShaderVariantCollection
                    //Shader.WarmupAllShaders();
                    if (null != cb)
                    {
                        cb();
                    }
                });
            }
            else
            {
                cb?.Invoke();
            }
        }
コード例 #6
0
        public void LoadFont(Action cb = null)
        {
            string assetPath = ResObjUtil.GetObjPath(fontAsset);

            BundleMgr.Instance.GetAsset(assetPath, (asset, cbId) =>
            {
                isFontLoaded = true;
                Font f       = asset as Font;
                mainFont     = f;
                if (null != f)
                {
                    if (!fonts.ContainsKey(f.name))
                    {
                        fonts.Add(f.name, f);
                    }
                }
                if (null != cb)
                {
                    cb();
                }
            });
        }