Esempio n. 1
0
        private void LoadAtlas(string atlasRes, Action cb = null)
        {
            string assetPath = ResObjUtil.GetObjPath(EObjType.ATLAS, 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))
                        {
                            Debugger.Log("atlas {0} sprite {1} already added", atlasRes, sprite.name);
                        }
                        else
                        {
                            cache.Add(sprite.name, sprite);
                        }
                    }
                }
                if (null != cb)
                {
                    cb();
                }
            });
        }
Esempio n. 2
0
 public void GetReady(string path, float volume, float pitch, bool loop)
 {
     ShutDown(false);
     isPlaying = false;
     assetPath = ResObjUtil.GetObjPath(EObjType.SOUND, path);
     assetCbId = BundleMgr.Instance.GetAsset(assetPath, (asset, cbId) =>
     {
         Play((AudioClip)asset, volume, pitch, loop);
         assetCbId = 0;
     });
 }
Esempio n. 3
0
        private void LoadShader(Action cb = null)
        {
            string assetPath = ResObjUtil.GetObjPath(EObjType.SHADERS, shaderAsset);

            BundleMgr.Instance.GetAsset(assetPath, (assets, cbId) =>
            {
                //暂时注释掉,现在会影响加载速度,预计替换为ShaderVariantCollection
                //Shader.WarmupAllShaders();
                if (null != cb)
                {
                    cb();
                }
            });
        }
Esempio n. 4
0
        private void LoadFont(Action cb = null)
        {
            string assetPath = ResObjUtil.GetObjPath(EObjType.FONT, fontAsset);

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