Пример #1
0
        internal void LayoutGUI()
        {
            var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label"));

            centeredStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label(new GUIContent("Bundle Pack Config"), centeredStyle);

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical();
            {
                m_PackConfig.OutputDirPath = EditorGUILayoutUtil.DrawDiskFolderSelection("Bundle Output", m_PackConfig.OutputDirPath);
                if (string.IsNullOrEmpty(m_PackConfig.OutputDirPath))
                {
                    m_PackConfig.OutputDirPath = GetDefaultOutputDir();
                }
                m_PackConfig.BuildTarget = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_PackConfig.BuildTarget);

                m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
                if (m_AdvancedSettings)
                {
                    EditorGUIUtil.BeginIndent();
                    {
                        m_PackConfig.CleanupBeforeBuild = EditorGUILayout.Toggle(m_CleanBeforeBuildContent, m_PackConfig.CleanupBeforeBuild);
                        m_PackConfig.Compression        = (CompressOptions)EditorGUILayout.IntPopup(m_CompressionContent, (int)m_PackConfig.Compression, m_CompressionContents, m_CompressionValues);

                        EditorGUILayout.Space();

                        EditorGUI.BeginChangeCheck();
                        {
                            m_IsForceRebuild = EditorGUILayout.Toggle(m_ForceRebuildContent, m_IsForceRebuild);
                            m_IsAppendHash   = EditorGUILayout.Toggle(m_AppendHashContent, m_IsAppendHash);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (m_IsForceRebuild)
                            {
                                m_PackConfig.BundleOptions |= BuildAssetBundleOptions.ForceRebuildAssetBundle;
                            }
                            else
                            {
                                m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.ForceRebuildAssetBundle;
                            }
                            if (m_IsAppendHash)
                            {
                                m_PackConfig.BundleOptions |= BuildAssetBundleOptions.AppendHashToAssetBundleName;
                            }
                            else
                            {
                                m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.AppendHashToAssetBundleName;
                            }
                        }
                    }
                    EditorGUIUtil.EndIndent();
                }

                EditorGUILayout.Space();
                if (GUILayout.Button("Pack Bundle"))
                {
                    EditorApplication.delayCall += () =>
                    {
                        BundlePackUtil.PackAssetBundle(m_PackConfig);
                    };
                }
            }
            EditorGUILayout.EndVertical();


            if (GUI.changed)
            {
                Util.FileUtil.SaveToBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath(), m_PackConfig);
            }
        }