コード例 #1
0
 /// <summary>
 /// 根据AB依赖二进制ab信息写一份txt的AB依赖信息文本
 /// </summary>
 private void writeABDepInfoIntoTxt()
 {
     if (isAssetBundleModule())
     {
         var assetbundleresourcemodule = ResourceModuleManager.getInstance().CurrentResourceModule as AssetBundleModule;
         var alldepinfomap             = assetbundleresourcemodule.AssetBundleDpMap;
         using (System.IO.StreamWriter sw = new System.IO.StreamWriter(Application.dataPath + "/../alldepab.txt"))
         {
             foreach (var depinfo in alldepinfomap)
             {
                 sw.WriteLine(depinfo.Key);
                 foreach (var dep in depinfo.Value)
                 {
                     sw.WriteLine("\t" + dep);
                 }
                 sw.WriteLine();
             }
             sw.Close();
             sw.Dispose();
         }
     }
     else
     {
         Debug.LogError("非AssetBundle模式下不支持输出AB依赖信息文件!");
     }
 }
コード例 #2
0
 /// <summary>
 /// 强制卸载指定AB
 /// </summary>
 /// <param name="abname"></param>
 private void forceUnloadSpecificAB(string abname)
 {
     if (isAssetBundleModule())
     {
         var assetbundleresourcemodule = ResourceModuleManager.getInstance().CurrentResourceModule as AssetBundleModule;
         assetbundleresourcemodule.forceUnloadSpecificResource(abname);
     }
     else
     {
         Debug.LogError("强制卸载指定AB功能只在AssetBundle模式下可用!");
     }
 }
コード例 #3
0
 /// <summary>
 /// 显示AB异步加载队列信息UI
 /// </summary>
 private void displayABAysncQueueInfoUI()
 {
     if (isAssetBundleModule())
     {
         var assetbundleresourcemodule = ResourceModuleManager.getInstance().CurrentResourceModule as AssetBundleModule;
         EditorGUILayout.BeginVertical();
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("当前AB异步加载队列信息 :");
         EditorGUILayout.EndHorizontal();
         var abasyncqueue = AssetBundleAsyncQueue.ABAsyncQueue;
         if (abasyncqueue.Count > 0)
         {
             foreach (var abasync in abasyncqueue)
             {
                 displayOneAssetBundleLoaderInfoUI(abasync);
             }
         }
         else
         {
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.LabelField("无", GUILayout.Width(250.0f));
             EditorGUILayout.EndHorizontal();
         }
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label(string.Format("当前AB异步加载携程总数量 : {0}", assetbundleresourcemodule.MaxMaximumAsyncCoroutine));
         EditorGUILayout.EndHorizontal();
         var abasyncqueuelist = assetbundleresourcemodule.AssetBundleAsyncQueueList;
         for (int i = 0; i < abasyncqueuelist.Count; i++)
         {
             displayOneAssetBundleAsyncQueueInfoUI(abasyncqueuelist[i], i);
         }
         EditorGUILayout.EndVertical();
     }
     else
     {
         GUILayout.BeginVertical();
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("AB异步加载队列信息只在AssetBundle模式下可用!");
         EditorGUILayout.EndHorizontal();
         EditorGUILayout.EndVertical();
     }
 }
コード例 #4
0
    /// <summary>
    /// 注册模块
    /// </summary>
    private void registerModules()
    {
        #region 资源模块
        ModuleManager.Singleton.registerModule <ResourceModuleManager>(ResourceModuleManager.getInstance());
        ModuleManager.Singleton.registerModule <ResourceManager>(ResourceManager.Singleton);
        ModuleManager.Singleton.registerModule <GameSceneManager>(GameSceneManager.Singleton);
        ModuleManager.Singleton.registerModule <WindowManager>(WindowManager.Singleton);
        ModuleManager.Singleton.registerModule <AtlasManager>(AtlasManager.Singleton);
        ModuleManager.Singleton.registerModule <AudioManager>(AudioManager.Singleton);
        ModuleManager.Singleton.registerModule <ModuleManager>(ModuleManager.Singleton);
        ModuleManager.Singleton.registerModule <EffectManager>(EffectManager.Singleton);
        ModuleManager.Singleton.registerModule <SharedTextureManager>(SharedTextureManager.Singleton);
        ModuleManager.Singleton.registerModule <SharedMaterialManager>(SharedMaterialManager.Singleton);
        #endregion

        #region 版本管理模块
        ModuleManager.Singleton.registerModule <VersionConfigManager>(VersionConfigManager.Singleton);
        #endregion

        #region 资源热更管理模块
        ModuleManager.Singleton.registerModule <HotUpdateModuleManager>(HotUpdateModuleManager.getInstance());
        #endregion
    }
コード例 #5
0
 /// <summary>
 /// 是否是AssetBundle模式
 /// </summary>
 /// <returns></returns>
 private bool isAssetBundleModule()
 {
     return(ResourceModuleManager.getInstance().CurrentResourceModule.ResLoadMode == ResourceLoadMode.AssetBundle);
 }
コード例 #6
0
    /// <summary>
    /// 显示资源使用索引信息UI
    /// </summary>
    private void displayABReferenceInfoUI()
    {
        var assetbundleresourcemodule = ResourceModuleManager.getInstance().CurrentResourceModule;

        EditorGUILayout.BeginVertical();
        var normalloadedabinfomap    = assetbundleresourcemodule.getSpecificLoadTypeARIMap(ResourceLoadType.NormalLoad);
        var preloadloadedabinfomap   = assetbundleresourcemodule.getSpecificLoadTypeARIMap(ResourceLoadType.Preload);
        var permanentloadedabinfomap = assetbundleresourcemodule.getSpecificLoadTypeARIMap(ResourceLoadType.PermanentLoad);

        if (!mTextFilter.Equals(string.Empty))
        {
            if (mFilterTextChanged)
            {
                mValideReferenceABInfoList.Clear();
                foreach (var normalloadedabinfo in normalloadedabinfomap)
                {
                    if (normalloadedabinfo.Key.StartsWith(mTextFilter))
                    {
                        mValideReferenceABInfoList.Add(normalloadedabinfo.Value);
                    }
                }

                foreach (var preloadloadedabinfo in preloadloadedabinfomap)
                {
                    if (preloadloadedabinfo.Key.StartsWith(mTextFilter))
                    {
                        mValideReferenceABInfoList.Add(preloadloadedabinfo.Value);
                    }
                }

                foreach (var permanentloadedabinfo in permanentloadedabinfomap)
                {
                    if (permanentloadedabinfo.Key.StartsWith(mTextFilter))
                    {
                        mValideReferenceABInfoList.Add(permanentloadedabinfo.Value);
                    }
                }

                if (mValideReferenceABInfoList.Count > 0)
                {
                    foreach (var validereferenceabinfo in mValideReferenceABInfoList)
                    {
                        displayOneAssetBundleInfoUI(validereferenceabinfo);
                    }
                }
                else
                {
                    GUILayout.Label(string.Format("找不到资源 : {0}的索引信息!", mTextFilter));
                }
            }
            else
            {
                if (mValideReferenceABInfoList.Count > 0)
                {
                    foreach (var validereferenceabinfo in mValideReferenceABInfoList)
                    {
                        displayOneAssetBundleInfoUI(validereferenceabinfo);
                    }
                }
                else
                {
                    GUILayout.Label(string.Format("找不到资源 : {0}的索引信息!", mTextFilter));
                }
            }
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("当前FPS : {0}", assetbundleresourcemodule.CurrentFPS));
            EditorGUILayout.EndHorizontal();
            if (assetbundleresourcemodule.ResLoadMode == ResourceLoadMode.AssetBundle)
            {
                var resourcemodule = assetbundleresourcemodule as AssetBundleModule;
                if (resourcemodule != null)
                {
                    var requestinfomap = resourcemodule.ABRequestTaskMap;
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(string.Format("加载队列信息 : {0}", requestinfomap.Count == 0 ? "无" : string.Empty));
                    EditorGUILayout.EndHorizontal();
                    foreach (var requestabl in requestinfomap)
                    {
                        displayOneAssetBundleLoaderInfoUI(requestabl.Value);
                    }
                }
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("资源加载队列信息只在AssetBundle模式下可用!");
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("正常已加载资源信息:");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("正常已加载资源数量 : {0}", normalloadedabinfomap.Count));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("可回收正常已加载非常驻资源数量 : {0}", assetbundleresourcemodule.getNormalUnsedABNumber()));
            EditorGUILayout.EndHorizontal();
            foreach (var loadedabi in normalloadedabinfomap)
            {
                displayOneAssetBundleInfoUI(loadedabi.Value);
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("预加载已加载资源信息:");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("预加载已加载资源数量 : {0}", preloadloadedabinfomap.Count));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("可回收预加载已加载非常驻资源数量 : {0}", assetbundleresourcemodule.getPreloadUnsedABNumber()));
            EditorGUILayout.EndHorizontal();
            foreach (var loadedabi in preloadloadedabinfomap)
            {
                displayOneAssetBundleInfoUI(loadedabi.Value);
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("常驻已加载资源信息:");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("已加载常驻资源数量 : {0}", permanentloadedabinfomap.Count));
            EditorGUILayout.EndHorizontal();
            foreach (var ploadedabi in permanentloadedabinfomap)
            {
                displayOneAssetBundleInfoUI(ploadedabi.Value);
            }
        }
        EditorGUILayout.EndVertical();
    }
コード例 #7
0
 /// <summary>
 /// 显示AB依赖信息UI
 /// </summary>
 private void displayABAllDepInfoUI()
 {
     if (isAssetBundleModule())
     {
         var assetbundleresourcemodule = ResourceModuleManager.getInstance().CurrentResourceModule as AssetBundleModule;
         GUILayout.BeginVertical();
         var alldepinfo = assetbundleresourcemodule.AssetBundleDpMap;
         if (!mTextFilter.Equals(string.Empty))
         {
             if (mFilterTextChanged)
             {
                 mValideDepABNameList.Clear();
                 foreach (var depinfo in alldepinfo)
                 {
                     if (depinfo.Key.StartsWith(mTextFilter))
                     {
                         mValideDepABNameList.Add(depinfo.Key);
                     }
                 }
                 if (mValideDepABNameList.Count > 0)
                 {
                     foreach (var abname in mValideDepABNameList)
                     {
                         GUILayout.Label(string.Format("{0} -> {1}", abname, getDepDes(alldepinfo[abname])));
                     }
                 }
                 else
                 {
                     GUILayout.Label(string.Format("找不到资源以 : {0}开头的依赖信息!", mTextFilter));
                 }
             }
             else
             {
                 if (mValideDepABNameList.Count > 0)
                 {
                     foreach (var abname in mValideDepABNameList)
                     {
                         GUILayout.Label(string.Format("{0} -> {1}", abname, getDepDes(alldepinfo[abname])));
                     }
                 }
                 else
                 {
                     GUILayout.Label(string.Format("找不到资源以 : {0}开头的依赖信息!", mTextFilter));
                 }
             }
         }
         else
         {
             int num = 0;
             foreach (var depinfo in alldepinfo)
             {
                 num++;
                 if (num < MaxDepABInfoNumber)
                 {
                     EditorGUILayout.BeginHorizontal();
                     GUILayout.Label(string.Format("{0} -> {1}", depinfo.Key, getDepDes(depinfo.Value)));
                     EditorGUILayout.EndHorizontal();
                 }
                 else
                 {
                     break;
                 }
             }
         }
         EditorGUILayout.EndVertical();
     }
     else
     {
         GUILayout.BeginVertical();
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("AB依赖信息只在AssetBundle模式下可用!");
         EditorGUILayout.EndHorizontal();
         EditorGUILayout.EndVertical();
     }
 }
コード例 #8
0
 private void OnGUI()
 {
     EditorGUILayout.BeginVertical();
     if (!EditorApplication.isPlaying)
     {
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("仅在运行模式下可用!");
         EditorGUILayout.EndHorizontal();
     }
     else
     {
         EditorGUILayout.BeginHorizontal();
         mLoggerSwitch = GUILayout.Toggle(mLoggerSwitch, "Unity Log总开关", GUILayout.Width(150.0f));
         if (mLoggerSwitch != Debug.unityLogger.logEnabled)
         {
             Debug.unityLogger.logEnabled = mLoggerSwitch;
         }
         ResourceLogger.LogSwitch = GUILayout.Toggle(ResourceLogger.LogSwitch, "是否开启资源Log", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f));
         GUILayout.Label("资源回收开关:" + ResourceModuleManager.getInstance().CurrentResourceModule.EnableResourceRecyclingUnloadUnsed, GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f));
         var preresourceloadmodeindex = ResourceLoadModeIndex;
         var newresourceloadmodeindex = EditorGUILayout.Popup(preresourceloadmodeindex, ResourceLoadModeChoices, GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f));
         if (preresourceloadmodeindex != newresourceloadmodeindex)
         {
             ResourceLoadModeIndex = newresourceloadmodeindex;
         }
         GUILayout.Label("资源回收开关:" + ResourceModuleManager.getInstance().CurrentResourceModule.EnableResourceRecyclingUnloadUnsed, GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f));
         EditorGUILayout.EndHorizontal();
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("筛选文本(默认不填表示显示所有):", GUILayout.MaxWidth(200.0f), GUILayout.MaxHeight(30.0f));
         var oldtextfilter = mTextFilter;
         mTextFilter = EditorGUILayout.TextField(mTextFilter, GUILayout.MaxWidth(100.0f), GUILayout.MaxHeight(30.0f));
         if (!oldtextfilter.Equals(mTextFilter))
         {
             mFilterTextChanged = true;
         }
         else
         {
             mFilterTextChanged = false;
         }
         EditorGUILayout.EndHorizontal();
         EditorGUILayout.BeginHorizontal();
         if (GUILayout.Button("查看AB依赖信息", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             mCurrentABDebugToolType = ABDebugToolType.AB_Display_All_Dep;
             mFilterTextChanged      = true;
         }
         if (GUILayout.Button("查看资源使用索引信息", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             mCurrentABDebugToolType = ABDebugToolType.AB_Display_AB_ReferenceInfo;
             mFilterTextChanged      = true;
         }
         if (GUILayout.Button("查看AB异步加载信息", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             mCurrentABDebugToolType = ABDebugToolType.AB_Display_Async_QueueInfo;
             mFilterTextChanged      = true;
         }
         if (GUILayout.Button("生成一份txt的AB依赖信息", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             writeABDepInfoIntoTxt();
         }
         if (GUILayout.Button("强制卸载指定AB", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             forceUnloadSpecificAB(mTextFilter);
         }
         if (GUILayout.Button("开启资源加载统计", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             ResourceLoadAnalyse.Singleton.ResourceLoadAnalyseSwitch = true;
             ResourceLoadAnalyse.Singleton.startResourceLoadAnalyse();
         }
         if (GUILayout.Button("结束资源加载统计", GUILayout.MaxWidth(120.0f), GUILayout.MaxHeight(30.0f)))
         {
             ResourceLoadAnalyse.Singleton.endResourceLoadAnalyse();
             ResourceLoadAnalyse.Singleton.ResourceLoadAnalyseSwitch = false;
         }
         EditorGUILayout.EndHorizontal();
         GUILayout.BeginVertical(GUILayout.MaxWidth(position.width), GUILayout.MaxHeight(position.height));
         mUiScrollPos   = GUILayout.BeginScrollView(mUiScrollPos);
         mDetailFoldOut = EditorGUILayout.Foldout(mDetailFoldOut, "详细数据展示区域:");
         if (mDetailFoldOut)
         {
             if (mCurrentABDebugToolType == ABDebugToolType.AB_Display_All_Dep)
             {
                 displayABAllDepInfoUI();
             }
             else if (mCurrentABDebugToolType == ABDebugToolType.AB_Display_AB_ReferenceInfo)
             {
                 displayABReferenceInfoUI();
             }
             else if (mCurrentABDebugToolType == ABDebugToolType.AB_Display_Async_QueueInfo)
             {
                 displayABAysncQueueInfoUI();
             }
         }
         GUILayout.EndScrollView();
         EditorGUILayout.EndVertical();
     }
     EditorGUILayout.EndVertical();
 }