示例#1
0
    public override void OnInspectorGUI()
    {
        GUI.skin.label.fontSize  = 12;
        GUI.skin.label.alignment = TextAnchor.MiddleLeft;
        GUI.skin.label.wordWrap  = true;

        GUILayout.Space(20);

        GUILayout.Label("输入或选择Manifest文件:");
        m_strManifestFilePath = EditorToolsMgr.TextField(m_strManifestFilePath, GUILayout.Height(15));
        if (GUILayout.Button("Manifest文件选择", GUILayout.Height(30)))
        {
            string path = EditorUtility.OpenFilePanel("请选择Manifest文件", m_strManifestFilePath ?? Application.dataPath, "");
            if (!string.IsNullOrEmpty(path))
            {
                m_strManifestFilePath = path;
            }
        }

        GUILayout.Space(20);

        m_bShowBatch = EditorGUILayout.Foldout(m_bShowBatch, "选择文件夹");
        if (m_bShowBatch)
        {
            GUILayout.Label("输入或选择文件夹:");
            m_strFolderPath = EditorToolsMgr.TextField(m_strFolderPath, GUILayout.Height(15));
            if (GUILayout.Button("文件夹选择", GUILayout.Height(30)))
            {
                string path = EditorUtility.OpenFolderPanel("请选择文件夹", m_strFolderPath ?? Application.dataPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    m_strFolderPath = path;
                }
            }

            GUILayout.Space(10);

            if (GUILayout.Button("批量添加依赖文件", GUILayout.Height(30)) && CheckFolderPath(m_strManifestFilePath, m_strFolderPath))
            {
                m_Component.BatchModify(m_strManifestFilePath, m_strFolderPath);
            }
        }

        GUILayout.Space(20);

        m_bShowSingle = EditorGUILayout.Foldout(m_bShowSingle, "选择文件");
        if (m_bShowSingle)
        {
            GUILayout.Label("输入或选择文件:");
            m_strFilePath = GUILayout.TextField(m_strFilePath, GUILayout.Height(15));
            if (GUILayout.Button("文件选择", GUILayout.Height(30)))
            {
                string path = EditorUtility.OpenFilePanel("请选择文件", m_strFilePath ?? Application.dataPath, "");

                if (!string.IsNullOrEmpty(path))
                {
                    m_strFilePath = path;
                }
            }

            GUILayout.Space(10);

            if (GUILayout.Button("添加依赖文件", GUILayout.Height(30)) && CheckFilePath(m_strManifestFilePath, m_strFilePath))
            {
                m_Component.SingleModify(m_strManifestFilePath, m_strFilePath);
            }
        }

        GUILayout.Space(20);
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        GUI.skin.label.fontSize  = 12;
        GUI.skin.label.alignment = TextAnchor.MiddleLeft;
        GUI.skin.label.wordWrap  = true;

        GUILayout.Space(20);

        m_bShowClear = EditorGUILayout.Foldout(m_bShowClear, "清理所有AB包名字");
        if (m_bShowClear)
        {
            if (GUILayout.Button("开始清理AB包名字", GUILayout.Height(30)))
            {
                string[] assetBundleNames = AssetDatabase.GetAllAssetBundleNames();

                string[] oldAssetBundleNames = new string[assetBundleNames.Length];
                for (int i = 0; i < assetBundleNames.Length; i++)
                {
                    oldAssetBundleNames[i] = assetBundleNames[i];

                    EditorUtility.DisplayProgressBar("正在获取已有的AB包名字", "已获取" + string.Format("{0}/{1}", i, assetBundleNames.Length), i / (float)assetBundleNames.Length);
                }

                for (int i = 0; i < assetBundleNames.Length; i++)
                {
                    AssetDatabase.RemoveAssetBundleName(oldAssetBundleNames[i], true);

                    EditorUtility.DisplayProgressBar("正在清理所有AB包名字", "已清理" + string.Format("{0}/{1}", i, assetBundleNames.Length), i / (float)assetBundleNames.Length);
                }

                EditorUtility.ClearProgressBar();
                Debug.Log("清理AB包名字完成");
            }
        }

        GUILayout.Space(20);

        m_bShowBuildAll = EditorGUILayout.Foldout(m_bShowBuildAll, "打包文件夹内资源");
        if (m_bShowBuildAll)
        {
            GUILayout.Label("输入或选择[打包]文件夹:");
            m_strAsbPath = EditorToolsMgr.TextField(m_strAsbPath, GUILayout.Height(15));
            if (GUILayout.Button("[打包]文件夹选择", GUILayout.Height(30)))
            {
                string path = EditorUtility.OpenFolderPanel("请选择文件夹", m_strAsbPath ?? Application.dataPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    m_strAsbPath = path;
                }
            }

            GUILayout.Space(10);

            GUILayout.Label("输入或选择[保存]文件夹:");
            m_strAsbSavePath = EditorToolsMgr.TextField(m_strAsbSavePath, GUILayout.Height(15));
            if (GUILayout.Button("[保存]文件夹选择", GUILayout.Height(30)))
            {
                string path = EditorUtility.OpenFolderPanel("请选择文件夹", m_strAsbSavePath ?? Application.dataPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    m_strAsbSavePath = path;
                }
            }

            GUILayout.Space(10);

            GUILayout.Label("打包到平台:");
            m_nSelectedPlatform = GUILayout.SelectionGrid(m_nSelectedPlatform, m_Options, m_Options.Length, GUI.skin.toggle);

            GUILayout.Space(10);

            if (GUILayout.Button("重命名所有AB包名字", GUILayout.Height(30)))
            {
                m_Component.RenameAllAssetBundlesName(m_strAsbPath);
            }

            GUILayout.Space(10);

            if (GUILayout.Button("开始打包所有AB包", GUILayout.Height(30)))
            {
                m_Component.StartAllBuild(m_strAsbPath, m_strAsbSavePath, m_nSelectedPlatform);
            }
        }

        GUILayout.Space(20);
    }