private BuildTarget LoalBuildTarget2UnityEngine(EditorBuildTarget target)
        {
            switch (target)
            {
            case EditorBuildTarget.Win64:
                return(BuildTarget.StandaloneWindows64);

            case EditorBuildTarget.Android:
                return(BuildTarget.Android);

            case EditorBuildTarget.iOS:
                return(BuildTarget.iOS);

            default:
                Debug.LogError("没有定义的类型 " + target);
                return(BuildTarget.StandaloneWindows);
            }
        }
Example #2
0
        private void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);

            m_BuildTarget = (EditorBuildTarget)EditorGUILayout.EnumPopup("打包目标平台", m_BuildTarget, GUILayout.Width(350));

            GUILayout.Label("需要打包的资源目录:");
            GUILayout.Space(5);

            GUILayout.Label("LuaAsset目录不需要被打包 ,而是生成LuaAsset目录:");
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            isSelectAll = GUILayout.Toggle(isSelectAll, new GUIContent("全部选中"));
            if (isSelectAll)
            {
                isDeSelectAll = false;
            }


            isDeSelectAll = GUILayout.Toggle(isDeSelectAll, new GUIContent("全部非选中"));
            if (isDeSelectAll)
            {
                isSelectAll = false;
            }

            GUILayout.EndHorizontal();

            if (isSelectAll && isDeSelectAll == false)
            {
                foreach (var item in m_AllResourcesTopPath)
                {
                    item.m_IsSelect = true;
                }
            }

            if (isSelectAll == false && isDeSelectAll)
            {
                foreach (var item in m_AllResourcesTopPath)
                {
                    item.m_IsSelect = false;
                }
            }


            m_ScrollRect = GUILayout.BeginScrollView(m_ScrollRect, true, true);
            for (int dex = 0; dex < m_AllResourcesTopPath.Count; ++dex)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(20));
                bool isSelect = GUILayout.Toggle(m_AllResourcesTopPath[dex].m_IsSelect, new GUIContent(GetRelativePath(m_AllResourcesTopPath[dex].m_AssetPath)));
                if (isSelect != m_AllResourcesTopPath[dex].m_IsSelect)
                {
                    m_AllResourcesTopPath[dex].m_IsSelect = isSelect;
                    isSelectAll = isDeSelectAll = false;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.Space(15);

            if (GUILayout.Button("开始生成AssetBundle", GUILayout.Height(50)))
            {
                Debug.Log("开始打包AssetBundle ...............");
                switch (m_BuildTarget)
                {
                case EditorBuildTarget.Android:
                    BuildAssetBundle_Tool.BegingPackAssetBundle(BuildTarget.Android, S_BuildAssetBundleWindow);
                    break;

                case EditorBuildTarget.Win64:
                    BuildAssetBundle_Tool.BegingPackAssetBundle(BuildTarget.StandaloneWindows64, S_BuildAssetBundleWindow);
                    break;

                case EditorBuildTarget.iOS:
                    BuildAssetBundle_Tool.BegingPackAssetBundle(BuildTarget.iOS, S_BuildAssetBundleWindow);
                    break;
                }
            }

            EditorGUILayout.EndVertical();
        }
        private void OnGUI()
        {
            #region 显示打包平台的枚举项
            GUILayout.Space(10);
            m_BuildTarget = (EditorBuildTarget)EditorGUILayout.EnumPopup("打包目标平台", m_BuildTarget, GUILayout.Width(350));

            #endregion

            #region 提示
            GUILayout.Label("需要打包的资源目录:");
            GUILayout.Space(5);

            GUILayout.Label("LuaAsset目录不需要被打包 ,而是生成LuaAsset目录:");
            GUILayout.Space(5);
            #endregion

            #region 全选、全部非选择

            GUILayout.BeginHorizontal();


            isSelectAll   = GUILayout.Toggle(isSelectAll, new GUIContent("全部选中"));
            isDeSelectAll = GUILayout.Toggle(isDeSelectAll, new GUIContent("全部非选中"));

            #region     设置状态

            if (isSelectAll)
            {
                isDeSelectAll = false;
                SelectAllAsset();
            }
            if (isDeSelectAll)
            {
                isSelectAll = false;
                UnSelectAllAsset();
            }
            #endregion

            GUILayout.EndHorizontal();
            #endregion

            #region  显示树形结构
            m_ScrollRect = GUILayout.BeginScrollView(m_ScrollRect, true, true);

            for (int dex = 0; dex < m_AllResourcesTopPath.Count; ++dex)
            {
                ShowSubFilePath(m_AllResourcesTopPath[dex], 1, true);
            }
            GUILayout.EndScrollView();
            GUILayout.Space(15);
            #endregion

            #region  显示打包按钮
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            if (GUILayout.Button(new GUIContent("开始打包"), GUILayout.Width(150), GUILayout.Height(50)))
            {
                S_BuildAssetBundleWindows.Close();
                BuildAssetBundleTool.BegingPackAssetBundle(LoalBuildTarget2UnityEngine(m_BuildTarget), S_BuildAssetBundleWindows);
            }
            GUILayout.EndVertical();
            #endregion
        }