コード例 #1
0
        void OnGUI()
        {
            // Use SerializedObject as a proxy to get dirty flags, undo & asset save
            GUILayout.Label("Output Settings", EditorStyles.boldLabel);

            // Need to use nested verticals and flexible space to align text & button vertically
            EditorGUILayout.BeginHorizontal(GUILayout.MaxHeight(GUI.skin.button.CalcHeight(new GUIContent("..."), 30)));
            // Also need a style on label to make it line up on the left edge
            EditorGUILayout.BeginVertical(LabelMarginStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("outputFolder"));
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
            {
                var prop = SerializedSettings.FindProperty("outputFolder");
                var fld  = EditorUtility.OpenFolderPanel("Pick build folder", prop.stringValue, PlayerSettings.productName);
                if (!string.IsNullOrEmpty(fld))
                {
                    prop.stringValue = fld;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("useProductName"));
            if (!Settings.useProductName)
            {
                EditorGUILayout.PropertyField(SerializedSettings.FindProperty("overrideName"));
            }
            EditorGUILayout.Space();


            GUILayout.Label("Platforms To Build", EditorStyles.boldLabel);

            bool        removeTargetAtEnd = false;
            BuildTarget targetToRemove    = BuildTarget.iOS;

            foreach (var target in Settings.targets)
            {
                EditorGUILayout.BeginHorizontal(RemoveButtonContainerStyle, GUILayout.MaxHeight(23));
                EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false), GUILayout.MinWidth(30));
                GUILayout.FlexibleSpace();
                GUI.backgroundColor = new Color(0.6f, 0, 0, 1);
                if (GUILayout.Button(" X ", ActionButtonStyle))
                {
                    // Don't do this now, breaks iteration
                    targetToRemove    = target;
                    removeTargetAtEnd = true;
                }
                GUI.backgroundColor = Color.white;
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField(target.ToString());
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
            if (Settings.targets.Count == 0)
            {
                GUILayout.Label("No platforms selected! Add one below.", EditorStyles.centeredGreyMiniLabel);
            }
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal(GUILayout.MaxHeight(GUI.skin.button.CalcHeight(new GUIContent("..."), 30)));
            EditorGUILayout.BeginVertical(LabelMarginStyle);
            GUILayout.FlexibleSpace();
            GUILayout.Label("Add platform");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            BuildTarget[] targets = (BuildTarget[])Enum.GetValues(typeof(BuildTarget));
            string[]      values  = new string[targets.Length];
            for (int i = 0; i < targets.Length; i++)
            {
                values[i] = targets[i].ToString();
            }
            _targetToAddIndex = EditorGUILayout.Popup(_targetToAddIndex, values);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add"))
            {
                var proplist = SerializedSettings.FindProperty("targets");
                proplist.arraySize++;
                SerializedProperty targetEnum = proplist.GetArrayElementAtIndex(proplist.arraySize - 1);
                int index = 0;
                foreach (string name in targetEnum.enumNames)
                {
                    if (name.ToLower().Equals(targets[_targetToAddIndex].ToString().ToLower()))
                    {
                        break;
                    }
                    index++;
                }
                proplist.GetArrayElementAtIndex(proplist.arraySize - 1).enumValueIndex = index;
                _targetsDirty = true;
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.Label("Additional options", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("developmentBuild"));
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("compress"));

            if (removeTargetAtEnd)
            {
                int index    = Settings.targets.IndexOf(targetToRemove);
                var proplist = SerializedSettings.FindProperty("targets");
                proplist.DeleteArrayElementAtIndex(index);
                _targetsDirty = true;
            }

            // This applies any changes to the underlying asset and marks dirty if needed
            // this is what ensures the asset gets saved
            SerializedSettings.ApplyModifiedProperties();
            if (_targetsDirty)
            {
                Repaint();
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUI.backgroundColor = new Color(0, 0.6f, 0, 1);
            if (GUILayout.Button("Build Selected Platforms", ActionButtonStyle, GUILayout.MinHeight(30)))
            {
                // do eet
                Build();
            }
        }
コード例 #2
0
        void OnGUI()
        {
            if (_targetsDirty)
            {
                UpdateTargetsNotAdded();
            }

            // Use SerializedObject as a proxy to get dirty flags, undo & asset save
            GUILayout.Label("Output Settings", EditorStyles.boldLabel);

            // Need to use nested verticals and flexible space to align text & button vertically
            EditorGUILayout.BeginHorizontal(GUILayout.MaxHeight(GUI.skin.button.CalcHeight(new GUIContent("..."), 30)));
            // Also need a style on label to make it line up on the left edge
            EditorGUILayout.BeginVertical(LabelMarginStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("outputFolder"));
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
            {
                var prop = SerializedSettings.FindProperty("outputFolder");
                var fld  = EditorUtility.OpenFolderPanel("Pick build folder", prop.stringValue, PlayerSettings.productName);
                if (!string.IsNullOrEmpty(fld))
                {
                    prop.stringValue = fld;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("useProductName"));
            if (!Settings.useProductName)
            {
                EditorGUILayout.PropertyField(SerializedSettings.FindProperty("overrideName"));
            }
            EditorGUILayout.Space();


            GUILayout.Label("Platforms To Build", EditorStyles.boldLabel);

            bool   removeTargetAtEnd = false;
            Target targetToRemove    = Target.iOS;

            foreach (var target in Settings.targets)
            {
                EditorGUILayout.BeginHorizontal(RemoveButtonContainerStyle, GUILayout.MaxHeight(23));
                EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false), GUILayout.MinWidth(30));
                GUILayout.FlexibleSpace();
                GUI.backgroundColor = new Color(0.6f, 0, 0, 1);
                if (GUILayout.Button(" X ", ActionButtonStyle))
                {
                    // Don't do this now, breaks iteration
                    targetToRemove    = target;
                    removeTargetAtEnd = true;
                }
                GUI.backgroundColor = Color.white;
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField(TargetNames[target]);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
            if (Settings.targets.Count == 0)
            {
                GUILayout.Label("No platforms selected! Add one below.", EditorStyles.centeredGreyMiniLabel);
            }
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal(GUILayout.MaxHeight(GUI.skin.button.CalcHeight(new GUIContent("..."), 30)));
            EditorGUILayout.BeginVertical(LabelMarginStyle);
            GUILayout.FlexibleSpace();
            GUILayout.Label("Add platform");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            _targetToAddIndex = EditorGUILayout.Popup(_targetToAddIndex, _targetNamesNotAdded.ToArray());
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add"))
            {
                // Ugh dealing with arrays in SerializedObject is awful
                string newTargetName = _targetNamesNotAdded[_targetToAddIndex];
                Target newTarget     = TargetNameToValue[newTargetName];
                // Insert in order
                var proplist = SerializedSettings.FindProperty("targets");
                int insertIndex;
                for (insertIndex = 0; insertIndex < proplist.arraySize; ++insertIndex)
                {
                    string name = TargetNames[(Target)proplist.GetArrayElementAtIndex(insertIndex).enumValueIndex];
                    if (string.Compare(newTargetName, name, true) < 0)
                    {
                        break;
                    }
                }
                proplist.arraySize++;
                // Move all existing items forward to make room for insert in order
                for (int i = proplist.arraySize - 1; i > insertIndex; --i)
                {
                    proplist.GetArrayElementAtIndex(i).enumValueIndex =
                        proplist.GetArrayElementAtIndex(i - 1).enumValueIndex;
                }
                proplist.GetArrayElementAtIndex(insertIndex).enumValueIndex = (int)newTarget;
                _targetsDirty = true;
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.Label("Additional options", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("developmentBuild"));

            if (removeTargetAtEnd)
            {
                int index    = Settings.targets.IndexOf(targetToRemove);
                var proplist = SerializedSettings.FindProperty("targets");
                proplist.DeleteArrayElementAtIndex(index);
                _targetsDirty = true;
            }

            // This applies any changes to the underlying asset and marks dirty if needed
            // this is what ensures the asset gets saved
            SerializedSettings.ApplyModifiedProperties();
            if (_targetsDirty)
            {
                Repaint();
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUI.backgroundColor = new Color(0, 0.6f, 0, 1);
            if (GUILayout.Button("Build Selected Platforms", ActionButtonStyle, GUILayout.MinHeight(30)))
            {
                // do eet
                Build();
            }
        }
コード例 #3
0
        void OnGUI()
        {
            SerializedSettings.Update();

            GUILayout.Label("OSX Build Notarization Settings", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("user"));
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Password");
            string pass = EditorGUILayout.PasswordField(password);

            if (!string.IsNullOrEmpty(pass))
            {
                password = pass;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("certId"));

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("bundleId"));

            EditorGUILayout.Space();

            EditorGUILayout.Space();

            GUILayout.Label("Entitlement options", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("mono"));
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("steamOverlay"));

            EditorGUILayout.Space();

            GuiLine();

            GUILayout.Label("Auto notarize options", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("autoNotarizeOnOSXBuild"));

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("blockUntilFinished"));

            EditorGUILayout.Space();

            GuiLine();

            GUILayout.Label("Manual notarization", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal(GUILayout.MaxHeight(GUI.skin.button.CalcHeight(new GUIContent("..."), 30)));
            EditorGUILayout.BeginVertical(LabelMarginStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.PropertyField(SerializedSettings.FindProperty("file"));
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
            {
                var    prop      = SerializedSettings.FindProperty("file");
                string directory = prop.stringValue;
                if (string.IsNullOrEmpty(prop.stringValue) && !string.IsNullOrEmpty(NotarizationProcessor.lastBuildFile))
                {
                    directory = NotarizationProcessor.lastBuildFile;
                }
                var fld = EditorUtility.OpenFilePanel("Pick file to notorize and press button", directory, "app");
                if (!string.IsNullOrEmpty(fld))
                {
                    prop.stringValue = fld;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            GUI.backgroundColor = new Color(0, 0.6f, 0, 1);
            if (GUILayout.Button("Notarize file", ActionButtonStyle, GUILayout.MinHeight(30)))
            {
                Notarize();
            }

            EditorGUILayout.Space();

            GUILayout.Label("After successful notarization (email)", EditorStyles.boldLabel);

            if (GUILayout.Button("Staple ticket to file", ActionButtonStyle, GUILayout.MinHeight(30)))
            {
                Staple();
            }

            EditorGUILayout.Space();

            GUILayout.Label("Notarization status", EditorStyles.boldLabel);

            if (GUILayout.Button("Get last status", ActionButtonStyle, GUILayout.MinHeight(30)))
            {
                NotarizationStatus();
            }

            if (status != null)
            {
                EditorGUILayout.Space();
                GUILayout.Label("Last Request: " + status.id, EditorStyles.label);
                GUILayout.Label("Date: " + status.dateTime, EditorStyles.label);
                GUILayout.Label("Status: " + (status.success ? "Successful" : "Failed"), EditorStyles.label);
                GUILayout.TextArea(status.url, EditorStyles.label);
            }

            EditorGUILayout.Space();

            GUILayout.Label("Notarized file valid", EditorStyles.boldLabel);

            if (GUILayout.Button("Validate notarized file", ActionButtonStyle, GUILayout.MinHeight(30)))
            {
                ValidateFile();
            }

            // GUIContent label = GUI.Label(yourLabelRect, status.url, EditorStyles.linkLabel);
            // Rect yourLabelRect = GUILayoutUtility.GetRect(status.url, EditorStyles.linkLabel);
            // if (Event.current.type == EventType.MouseUp && yourLabelRect.Contains(Event.current.mousePosition))
            //     Application.OpenURL(status.url);

            // This applies any changes to the underlying asset and marks dirty if needed
            // this is what ensures the asset gets saved
            SerializedSettings.ApplyModifiedProperties();
        }