示例#1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, GUIContent.none, property);

            EditorGUILayout.BeginHorizontal();

            bool show = property.isExpanded;

            UnityBuildGUIUtility.DropdownHeader("Product Parameters", ref show, false, GUILayout.ExpandWidth(true));
            property.isExpanded = show;

            UnityBuildGUIUtility.HelpButton("Parameter-Details#product-parameters");
            EditorGUILayout.EndHorizontal();

            if (show)
            {
                EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                SerializedProperty autoGenerate           = property.FindPropertyRelative("autoGenerate");
                SerializedProperty syncWithPlayerSettings = property.FindPropertyRelative("syncWithPlayerSettings");

                EditorGUI.BeginDisabledGroup(syncWithPlayerSettings.boolValue);
                EditorGUILayout.PropertyField(property.FindPropertyRelative("version"));

                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.PropertyField(property.FindPropertyRelative("lastGeneratedVersion"));
                EditorGUI.EndDisabledGroup();

                autoGenerate.boolValue = EditorGUILayout.ToggleLeft("Auto-Generate Version", autoGenerate.boolValue);
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(autoGenerate.boolValue);
                syncWithPlayerSettings.boolValue = EditorGUILayout.ToggleLeft("Sync Version with Player Settings", syncWithPlayerSettings.boolValue);
                EditorGUI.EndDisabledGroup();

                if (syncWithPlayerSettings.boolValue)
                {
                    property.FindPropertyRelative("version").stringValue = PlayerSettings.bundleVersion;
                }

                EditorGUILayout.PropertyField(property.FindPropertyRelative("buildCounter"));

                if (GUILayout.Button("Reset Build Counter", GUILayout.ExpandWidth(true)))
                {
                    property.FindPropertyRelative("buildCounter").intValue = 0;
                }

                if (!autoGenerate.boolValue && !syncWithPlayerSettings.boolValue && GUILayout.Button("Generate Version String Now", GUILayout.ExpandWidth(true)))
                {
                    BuildProject.GenerateVersionString(BuildSettings.productParameters, DateTime.Now);
                }

                property.serializedObject.ApplyModifiedProperties();

                EditorGUILayout.EndVertical();
            }

            EditorGUI.EndProperty();
        }
示例#2
0
        public static void PerformBuild()
        {
            //string[] args = System.Environment.GetCommandLineArgs();
            BuildProject.BuildAll();

            // Exit w/ 0 to indicate success.
            EditorApplication.Exit(0);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            showViewOptions  = property.FindPropertyRelative("showViewOptions");
            showConfigs      = property.FindPropertyRelative("showConfigs");
            showBuildInfo    = property.FindPropertyRelative("showBuildInfo");
            hideDisabled     = property.FindPropertyRelative("hideDisabled");
            treeView         = property.FindPropertyRelative("treeView");
            selectedKeyChain = property.FindPropertyRelative("selectedKeyChain");

            EditorGUI.BeginProperty(position, label, property);

            EditorGUILayout.BeginHorizontal();

            show = property.isExpanded;
            UnityBuildGUIUtility.DropdownHeader("Build Configurations", ref show, false, GUILayout.ExpandWidth(true));
            property.isExpanded = show;

            UnityBuildGUIUtility.HelpButton("Parameter-Details#build-configurations");
            EditorGUILayout.EndHorizontal();

            Color defaultBackgroundColor = GUI.backgroundColor;

            if (show)
            {
                EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                EditorGUILayout.BeginHorizontal();
                show = showViewOptions.isExpanded;
                UnityBuildGUIUtility.DropdownHeader("View Options", ref show, false, GUILayout.ExpandWidth(true));
                showViewOptions.isExpanded = show;
                EditorGUILayout.EndHorizontal();

                if (show)
                {
                    EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                    hideDisabled.boolValue = EditorGUILayout.ToggleLeft("Hide disabled configurations", hideDisabled.boolValue);
                    treeView.boolValue     = EditorGUILayout.ToggleLeft("Show full configurations tree", treeView.boolValue);

                    EditorGUILayout.EndVertical();
                }

                GUILayout.Space(5);
                EditorGUILayout.BeginHorizontal();
                show = showConfigs.isExpanded;
                UnityBuildGUIUtility.DropdownHeader("Configurations", ref show, false, GUILayout.ExpandWidth(true));
                showConfigs.isExpanded = show;
                EditorGUILayout.EndHorizontal();

                if (show)
                {
                    EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                    if (BuildSettings.projectConfigurations.configSet.Keys.Count > 0)
                    {
                        BuildReleaseType[] releaseTypes = BuildSettings.releaseTypeList.releaseTypes;
                        for (int i = 0; i < releaseTypes.Length; i++)
                        {
                            string        key    = releaseTypes[i].typeName;
                            Configuration config = BuildSettings.projectConfigurations.configSet[key];
                            DisplayConfigTree(key, config, 0);
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No Configuration info. Please add a Release Type.", MessageType.Error);
                    }

                    EditorGUILayout.EndVertical();
                }

                GUILayout.Space(5);
                EditorGUILayout.BeginHorizontal();
                show = showBuildInfo.isExpanded;
                UnityBuildGUIUtility.DropdownHeader("Build Info", ref show, false, GUILayout.ExpandWidth(true));
                showBuildInfo.isExpanded = show;
                EditorGUILayout.EndHorizontal();

                if (show)
                {
                    EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                    if (string.IsNullOrEmpty(selectedKeyChain.stringValue))
                    {
                        EditorGUILayout.HelpBox("Click a build configuration above in \"Configurations\" to view full details.", MessageType.Info);
                    }
                    else
                    {
                        BuildReleaseType  releaseType;
                        BuildPlatform     platform;
                        BuildArchitecture arch;
                        BuildDistribution dist;
                        BuildOptions      buildOptions = BuildOptions.None;

                        bool parseSuccess = BuildSettings.projectConfigurations.ParseKeychain(selectedKeyChain.stringValue, out releaseType, out platform, out arch, out dist);

                        if (parseSuccess)
                        {
                            string defines = BuildProject.GenerateDefaultDefines(releaseType, platform, arch, dist);

                            EditorGUILayout.LabelField("Misc Info", UnityBuildGUIUtility.midHeaderStyle);
                            EditorGUILayout.LabelField("Defines:");
                            EditorGUILayout.LabelField(defines, EditorStyles.wordWrappedLabel);

                            if (releaseType != null)
                            {
                                buildOptions = releaseType.buildOptions;
                                EditorGUILayout.LabelField("Release Type", UnityBuildGUIUtility.midHeaderStyle);
                                EditorGUILayout.LabelField("Type Name:\t" + releaseType.typeName);

                                if (!string.IsNullOrEmpty(releaseType.bundleIdentifier))
                                {
                                    EditorGUILayout.LabelField("Bundle Identifier:\t" + releaseType.bundleIdentifier);
                                }

                                EditorGUILayout.LabelField("Product Name:\t" + releaseType.productName);
                            }

                            if (platform != null)
                            {
                                EditorGUILayout.LabelField("Platform", UnityBuildGUIUtility.midHeaderStyle);
                                EditorGUILayout.LabelField("Name:\t\t" + platform.platformName);
                            }

                            if (arch != null)
                            {
                                EditorGUILayout.LabelField("Architecture", UnityBuildGUIUtility.midHeaderStyle);
                                EditorGUILayout.LabelField("Name:\t\t" + arch.name);
                            }

                            if (dist != null)
                            {
                                EditorGUILayout.LabelField("Distribution", UnityBuildGUIUtility.midHeaderStyle);
                                EditorGUILayout.LabelField("Name:\t\t" + dist.distributionName);
                            }

                            GUILayout.Space(20);
                            GUI.backgroundColor = Color.green;
                            if (GUILayout.Button("Build", GUILayout.ExpandWidth(true)))
                            {
                                BuildOptions finalBuildOptions = buildOptions;
                                EditorApplication.delayCall += () =>
                                                               BuildProject.BuildSingle(selectedKeyChain.stringValue, finalBuildOptions);
                            }
                            if (GUILayout.Button("Build and Run", GUILayout.ExpandWidth(true)))
                            {
                                buildOptions |= BuildOptions.AutoRunPlayer;
                                BuildOptions finalBuildOptions = buildOptions;
                                EditorApplication.delayCall += () =>
                                                               BuildProject.BuildSingle(selectedKeyChain.stringValue, finalBuildOptions);
                            }

                            EditorGUI.BeginDisabledGroup((buildOptions & BuildOptions.Development) != BuildOptions.Development);
                            if (GUILayout.Button("Build and Run with Profiler", GUILayout.ExpandWidth(true)))
                            {
                                buildOptions |= BuildOptions.AutoRunPlayer;
                                buildOptions |= BuildOptions.ConnectWithProfiler;
                                BuildOptions finalBuildOptions = buildOptions;
                                EditorApplication.delayCall += () =>
                                                               BuildProject.BuildSingle(selectedKeyChain.stringValue, finalBuildOptions);
                            }
                            EditorGUI.EndDisabledGroup();
                            GUI.backgroundColor = defaultBackgroundColor;

                            if (GUILayout.Button(new GUIContent("Configure Editor Environment", "Switches platform, refreshes BuildConstants, applies scripting defines and variant settings and sets Build Settings scene list to match the selected build configuration"), GUILayout.ExpandWidth(true)))
                            {
                                // Update Editor environment settings to match selected build configuration
                                BuildProject.ConfigureEnvironment(releaseType, platform, arch, dist, DateTime.Now);

                                // Apply scene list
                                BuildProject.SetEditorBuildSettingsScenes(releaseType);
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Could not parse selected configuration. It may no longer be valid due to a change. Select again.", MessageType.Info);
                        }
                    }

                    EditorGUILayout.EndVertical();
                }

                property.serializedObject.ApplyModifiedProperties();

                EditorGUILayout.EndVertical();
            }

            EditorGUI.EndProperty();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            // Limit valid characters.
            // TODO: This might not be necessary since name will need to be sanitized for different needs later (as an enum entry, pre-processor define, etc.)
            //char chr = Event.current.character;
            //if ((chr < 'a' || chr > 'z') && (chr < 'A' || chr > 'Z') && (chr < '0' || chr > '9') && chr != '-' && chr != '_' && chr != ' ')
            //{
            //    Event.current.character = '\0';
            //}

            bool show = property.isExpanded;

            UnityBuildGUIUtility.DropdownHeader(property.FindPropertyRelative("typeName").stringValue, ref show, false);
            property.isExpanded = show;

            if (show)
            {
                EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                GUILayout.Label("Basic Info", UnityBuildGUIUtility.midHeaderStyle);

                SerializedProperty typeName = property.FindPropertyRelative("typeName");

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Type Name");
                typeName.stringValue = BuildProject.SanitizeFolderName(GUILayout.TextArea(typeName.stringValue));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.PropertyField(property.FindPropertyRelative("bundleIdentifier"));
                EditorGUILayout.PropertyField(property.FindPropertyRelative("productName"));
                EditorGUILayout.PropertyField(property.FindPropertyRelative("companyName"));

                GUILayout.Space(20);
                GUILayout.Label("Build Options", UnityBuildGUIUtility.midHeaderStyle);

                EditorGUILayout.PropertyField(property.FindPropertyRelative("customDefines"));

                SerializedProperty buildOptions = property.FindPropertyRelative("buildOptions");

                bool enableHeadlessMode = ((BuildOptions)buildOptions.intValue & BuildOptions.EnableHeadlessMode) == BuildOptions.EnableHeadlessMode;
                bool developmentBuild   = ((BuildOptions)buildOptions.intValue & BuildOptions.Development) == BuildOptions.Development;
                bool allowDebugging     = ((BuildOptions)buildOptions.intValue & BuildOptions.AllowDebugging) == BuildOptions.AllowDebugging;

                enableHeadlessMode = EditorGUILayout.ToggleLeft(" Server Build", enableHeadlessMode);
                if (enableHeadlessMode)
                {
                    buildOptions.intValue |= (int)BuildOptions.EnableHeadlessMode;
                }
                else
                {
                    buildOptions.intValue &= ~(int)BuildOptions.EnableHeadlessMode;
                }

                developmentBuild = EditorGUILayout.ToggleLeft(" Development Build", developmentBuild);
                if (developmentBuild)
                {
                    buildOptions.intValue |= (int)BuildOptions.Development;
                }
                else
                {
                    buildOptions.intValue &= ~(int)BuildOptions.Development;
                }

                EditorGUI.BeginDisabledGroup(!developmentBuild);
                allowDebugging = EditorGUILayout.ToggleLeft(" Script Debugging", allowDebugging);
                EditorGUI.EndDisabledGroup();
                if (allowDebugging)
                {
                    buildOptions.intValue |= (int)BuildOptions.AllowDebugging;
                }
                else
                {
                    buildOptions.intValue &= ~(int)BuildOptions.AllowDebugging;
                }

                GUILayout.Space(15);
                buildOptions.intValue = (int)(BuildOptions)EditorGUILayout.EnumFlagsField("Advanced Options", (BuildOptions)buildOptions.intValue);

                EditorGUILayout.PropertyField(property.FindPropertyRelative("sceneList"));

                if (GUILayout.Button("Delete", GUILayout.ExpandWidth(true)))
                {
                    BuildReleaseType[] types = BuildSettings.releaseTypeList.releaseTypes;
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (types[i].typeName == property.FindPropertyRelative("typeName").stringValue)
                        {
                            ArrayUtility.RemoveAt <BuildReleaseType>(ref BuildSettings.releaseTypeList.releaseTypes, i);
                            GUIUtility.keyboardControl = 0;
                            break;
                        }
                    }
                }

                property.serializedObject.ApplyModifiedProperties();

                EditorGUILayout.EndVertical();
            }

            EditorGUI.EndProperty();
        }
示例#5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, GUIContent.none, property);

            bool show = property.isExpanded;

            UnityBuildGUIUtility.DropdownHeader(property.FindPropertyRelative("platformName").stringValue, ref show, false);
            property.isExpanded = show;

            if (show)
            {
                EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                SerializedProperty archList = property.FindPropertyRelative("architectures");

                if (archList.arraySize > 1)
                {
                    GUILayout.Label("Architectures", UnityBuildGUIUtility.midHeaderStyle);
                    for (int i = 0; i < archList.arraySize; i++)
                    {
                        SerializedProperty archProperty = archList.GetArrayElementAtIndex(i);
                        SerializedProperty archName     = archProperty.FindPropertyRelative("name");
                        SerializedProperty archEnabled  = archProperty.FindPropertyRelative("enabled");

                        archEnabled.boolValue = GUILayout.Toggle(archEnabled.boolValue, archName.stringValue);
                        archProperty.serializedObject.ApplyModifiedProperties();
                    }
                }

                SerializedProperty variantList = property.FindPropertyRelative("variants");

                if (variantList.arraySize > 0)
                {
                    GUILayout.Label("Variant Options", UnityBuildGUIUtility.midHeaderStyle);

                    for (int i = 0; i < variantList.arraySize; i++)
                    {
                        SerializedProperty variantProperty      = variantList.GetArrayElementAtIndex(i);
                        SerializedProperty variantName          = variantProperty.FindPropertyRelative("variantName");
                        SerializedProperty variantValues        = variantProperty.FindPropertyRelative("values");
                        SerializedProperty selectedVariantIndex = variantProperty.FindPropertyRelative("selectedIndex");

                        List <string> valueNames = new List <string>(variantValues.arraySize);
                        for (int j = 0; j < variantValues.arraySize; j++)
                        {
                            valueNames.Add(variantValues.GetArrayElementAtIndex(j).stringValue);
                        }

                        GUILayout.BeginHorizontal();

                        EditorGUILayout.LabelField(variantName.stringValue);
                        selectedVariantIndex.intValue =
                            EditorGUILayout.Popup(selectedVariantIndex.intValue, valueNames.ToArray(), UnityBuildGUIUtility.popupStyle, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(250));

                        GUILayout.EndHorizontal();
                    }
                }

                SerializedProperty distList = property.FindPropertyRelative("distributionList.distributions");

                if (distList.arraySize > 0)
                {
                    GUILayout.Label("Distributions", UnityBuildGUIUtility.midHeaderStyle);

                    for (int i = 0; i < distList.arraySize; i++)
                    {
                        SerializedProperty dist        = distList.GetArrayElementAtIndex(i);
                        SerializedProperty distEnabled = dist.FindPropertyRelative("enabled");
                        SerializedProperty distName    = dist.FindPropertyRelative("distributionName");

                        GUILayout.BeginHorizontal();

                        distEnabled.boolValue = GUILayout.Toggle(distEnabled.boolValue, GUIContent.none, GUILayout.ExpandWidth(false));
                        distName.stringValue  = BuildProject.SanitizeFolderName(GUILayout.TextField(distName.stringValue));

                        if (GUILayout.Button("X", UnityBuildGUIUtility.helpButtonStyle))
                        {
                            distList.DeleteArrayElementAtIndex(i);
                        }

                        dist.serializedObject.ApplyModifiedProperties();

                        GUILayout.EndHorizontal();
                    }
                }

                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                if (GUILayout.Button("Add Distribution", GUILayout.MaxWidth(150)))
                {
                    int addedIndex = distList.arraySize;
                    distList.InsertArrayElementAtIndex(addedIndex);

                    SerializedProperty addedProperty = distList.GetArrayElementAtIndex(addedIndex);
                    addedProperty.FindPropertyRelative("enabled").boolValue            = true;
                    addedProperty.FindPropertyRelative("distributionName").stringValue = "DistributionName";

                    addedProperty.serializedObject.ApplyModifiedProperties();
                    distList.serializedObject.ApplyModifiedProperties();
                    property.serializedObject.ApplyModifiedProperties();
                    GUIUtility.keyboardControl = 0;
                }
                if (GUILayout.Button("Delete Platform", GUILayout.MaxWidth(150)))
                {
                    property.FindPropertyRelative("enabled").boolValue = false;
                }
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                EditorGUILayout.EndVertical();
            }

            property.serializedObject.ApplyModifiedProperties();

            EditorGUI.EndProperty();
        }