Example #1
0
    private void OnGUI()
    {
        //释放所有ab
        if (GUILayout.Button("释放所有ab"))
        {
            AssetMgr.dispose(true);
        }

        //释放所有池子
        if (GUILayout.Button("释放所有池子"))
        {
            PoolMgr.Instance.onDispose();
        }

        //释放一个池子
        if (GUILayout.Button("释放一个池子"))
        {
            if (roleObj != null)
            {
                string resName = roleObj.GetComponent <PoolObj>().resName;
                PoolMgr.Instance.disposePool(resName);
                UnityEngine.Debug.LogError("释放池子 " + resName);
            }
        }

        //创建一个模型
        if (GUILayout.Button("创建一个模型"))
        {
            //watch.Start();
            string role = "AssetBundle/Prefabs/model/role_ueman/model/role_ueman";
            UnityEngine.Debug.LogError("加载role_ueman");
            PoolMgr.Instance.getObj(role, onLoadUEManFinish);
            //UnityEngine.Debug.LogError("取消加载role_ueman");
            //PoolMgr.Instance.unLoad(role, onLoadUEManFinish);
        }
        //回收一个模型
        if (GUILayout.Button("回收一个模型"))
        {
            PoolMgr.Instance.recyleObj(roleObj);
        }

        //设置img的sprite
        if (GUILayout.Button("设置img的sprite"))
        {
            if (img != null)
            {
                string spName = "CZ_5".ToLower();
                PoolMgr.Instance.getObj(spName, (sp, resName) =>
                {
                    img.sprite = sp;
                });
            }
            else
            {
                UnityEngine.Debug.LogError("img == null ");
            }
        }
        //预加载模型
        if (GUILayout.Button("预加载"))
        {
            watch.Start();
            foreach (var item in preLoads)
            {
                E_PoolType pType      = item.Key;
                int        cacheCount = pType == E_PoolType.Model ? 3 : pType == E_PoolType.UICache ? 2 : 0;
                for (int i = 0; i < item.Value.Count; i++)
                {
                    PoolMgr.Instance.preLoad(item.Value[i], preLoadCount, E_PoolMode.Overall, pType, cacheCount);
                }
            }
        }

        //打开技能UI
        if (GUILayout.Button("打开技能UI"))
        {
            string uiName = "assetbundle/prefabs/ui/BottomSkillUI";
            PoolMgr.Instance.getObj(uiName, onLoadSkillUIFinish);
        }
    }