Inheritance: MonoBehaviour
Example #1
0
    public static string SearchFilter(string text, string defaultString, params GUILayoutOption[] options)
    {
        GUILayout.BeginHorizontal(options);

        GUI.SetNextControlName("SearchFilterTextField");
        bool focused = GUI.GetNameOfFocusedControl() == "SearchFilterTextField";

        if (focused)
        {
            defaultString = text;
        }

        Color?    color = focused ? null : new Nullable <Color>(EditorStylesExt.EditorDarkGray);
        FontStyle?style = focused ? null : new Nullable <FontStyle>(FontStyle.Italic);

        EditorGUILayoutExt.BeginStyle(EditorStylesExt.SearchTextField, null, style, color, null);
        string newText = GUILayout.TextField(defaultString, EditorStylesExt.SearchTextField);

        EditorGUILayoutExt.EndStyle();

        if (focused)
        {
            text = newText;
        }

        if (GUILayout.Button("", EditorStylesExt.SearchCancelButton))
        {
            text = "";
        }
        GUILayout.EndHorizontal();
        return(text);
    }
Example #2
0
        void DrawObjectFieldGUI(ref string name, ref UnityObject scene)
        {
            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            {
                var lastVal = scene;
#if !(Unity3 || Unity4_0To4_2)
                GUILayout.BeginHorizontal();
                name = GUILayout.TextField(name, GUILayout.Width(EditorGUIUtility.labelWidth));
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(SceneAsset), true);
#else
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(UnityObject), true);
#endif
                GUILayout.EndHorizontal();
#else
                scene = EditorGUILayoutExt.ObjectField(name, scene, typeof(UnityObject), true);
#endif
                if (scene != lastVal)
                {
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (scene)
                    {
                        name = scene.name;
                    }
                    else
                    {
                        name = string.Empty;
                    }
                }
            }
            GUILayout.EndVertical();
        }
Example #3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        owner     = (target as NavMeshTool);
        _property = owner?.data;
        EditorGUILayoutExt.FloatField("地图宽度", _property.endX - _property.startX);
        EditorGUILayoutExt.FloatField("地图高度", _property.endZ - _property.startZ);
        if (GUILayout.Button("测试地图大小"))
        {
            CreateMapTestMesh();
        }

        if (_property.mapID == -1)
        {
            CheckInit();
        }

        EditorGUILayout.Separator();
        if (GUILayout.Button("生成寻路数据"))
        {
            CreateNavMeshData();
        }

        EditorGUILayout.Separator();
    }
Example #4
0
    public override void OnInspectorGUI()
    {
        BasicLineRenderer basicLineRenderer = target as BasicLineRenderer;

        DrawDefaultInspector();
        EditorGUILayoutExt.Vector3ArrayField(ref basicLineRenderer.positions, "Positions", ref positionsExpanded);
        basicLineRenderer.UpdateMesh();
    }
Example #5
0
        public static void DrawProperty(ref OBB2D shape)
        {
            shape.size = EditorGUILayoutExt.Vector2Field("Size", shape.size);
            var deg = EditorGUILayoutExt.FloatField("Deg", shape.deg);

            if (deg != shape.deg)
            {
                shape.SetDeg(deg);
            }
        }
Example #6
0
    public static bool DrawCustomEventInspectorBar(bool expanded, GameObject senderGameObject, out EventSender newSender)
    {
        EventSender sender = senderGameObject.GetComponent <EventSender>();

        EditorGUILayout.BeginHorizontal();

        EditorGUILayoutExt.BeginLabelStyle(12, FontStyle.Bold, new Color(0.45f, 0.45f, 0.45f), null);

        expanded = GUILayout.Button(expanded ? "▼" : "►", GUI.skin.label, GUILayout.ExpandWidth(false)) ? !expanded : expanded;
        if (sender != null)
        {
            bool enabled = GUILayout.Toggle(sender.enabled, "", GUILayout.ExpandWidth(false));
            if (enabled != sender.enabled)
            {
                sender.enabled = enabled;
            }
        }
        EditorGUILayoutExt.BeginLabelStyle(null, null, new Color(0.72f, 1f, 0.72f), null);
        if (sender != null)
        {
            expanded = GUILayout.Button(sender.GetType().Name, GUI.skin.label, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)) ? !expanded : expanded;
        }
        else
        {
            expanded = GUILayout.Button("Event: None!", GUI.skin.label, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)) ? !expanded : expanded;
        }
        GUILayout.FlexibleSpace();
        GUILayout.FlexibleSpace();

        EditorGUILayoutExt.EndLabelStyle();
        EditorGUILayoutExt.EndLabelStyle();

        Type eventType = TriggerGUILayout.DrawEventSelector(sender != null ? sender.GetType() : null);

        if (eventType != null)
        {
            if (sender == null || eventType != sender.GetType())
            {
                GameObject.DestroyImmediate(sender);
                sender = (EventSender)senderGameObject.AddComponent(eventType);
            }
        }
        else
        {
            GameObject.DestroyImmediate(sender);
            sender = null;
        }

        EditorGUILayout.EndHorizontal();

        newSender = sender;
        return(expanded);
    }
    void OnGUI()
    {
        GUILayout.BeginArea(new Rect(0, 0, position.width, position.height));
        GUILayout.BeginVertical(EditorStylesExt.GreyBorder);
        GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

        GUI.SetNextControlName("TagTextField");
        if (EditorGUILayoutExt.EnterableTextField(ref _searchField))
        {
            _selectionCallback(_searchField);
            Close();
        }



        _scroll = GUILayout.BeginScrollView(_scroll);


        foreach (string tagCandidate in _allTags)
        {
            if (!string.IsNullOrEmpty(_searchField))
            {
                if (!tagCandidate.StartsWith(_searchField, StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }
            }
            if (GUILayout.Button(tagCandidate, EditorStylesExt.MiniButtonMiddle))
            {
                _selectionCallback(tagCandidate);
                Close();
            }
        }

        GUILayout.EndScrollView();



        GUILayout.EndVertical();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add", EditorStylesExt.ButtonMiddle))
        {
            _selectionCallback(_searchField);
            Close();
        }
        if (GUILayout.Button("Cancel", EditorStylesExt.ButtonMiddle))
        {
            Close();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Example #8
0
        void ShowShape <T>(ref T circle, int idx, FuncDrawProperty <T> _Func) where T : IShape2D
        {
            GUILayout.BeginVertical();
            var offset = EditorGUILayoutExt.Vector2Field("Offset", owner.allOffsets[idx]);

            owner.allOffsets[idx] = offset;
            circle.UpdatePosition(owner.pos + offset);
            {
                GUILayout.BeginHorizontal();
                _Func(ref circle);
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Example #9
0
        void ShowShape <T>(T circle, int idx, System.Action <T> _Func) where T : BaseShaper2D
        {
            GUILayout.BeginVertical();
            var offset = EditorGUILayoutExt.Vector2Field("Offset", owner.allOffsets[idx]);

            owner.allOffsets[idx] = offset;
            circle.UpdatePosition(owner.pos + offset);

            {
                GUILayout.BeginHorizontal();
                _Func(circle);
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Example #10
0
    public void Draw(int depth)
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(15 * depth);

        if (HasChildren)
        {
            bool contracted = _overviewContext.ContractedNodes.Contains(GameObject);
            if (GUILayout.Button(contracted ? "►" : "▼", GUI.skin.label, GUILayout.ExpandWidth(false)))
            {
                if (contracted)
                {
                    _overviewContext.ContractedNodes.Remove(GameObject);
                    //_context.Repaint();
                }
                else
                {
                    _overviewContext.ContractedNodes.Add(GameObject);
                    //_context.Repaint();
                }
            }
        }
        else
        {
            EditorGUILayoutExt.BeginLabelStyle(null, null, new Color(0.35f, 0.35f, 0.35f, 1.0f), null);
            GUILayout.Button("▼", GUI.skin.label, GUILayout.ExpandWidth(false));
            EditorGUILayoutExt.EndLabelStyle();
        }

        if (Trigger)
        {
            DrawTriggerNode();
        }
        else if (GameObject)
        {
            DrawFolderNode();
        }

        EditorGUILayout.EndHorizontal();

        if (!_overviewContext.ContractedNodes.Contains(GameObject))
        {
            foreach (TriggerCollectionNode child in this)
            {
                child.Draw(depth + 1);
            }
        }
    }
Example #11
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        owner = target as EnemyView;
        force = EditorGUILayoutExt.Vector3Field("force", force);
        if (GUILayout.Button("AddImpulse"))
        {
            owner.owner.rigidbody.AddImpulse(force);
        }

        resetYSpd = EditorGUILayoutExt.FloatField("resetYSpd", resetYSpd);
        if (GUILayout.Button("ResetSpeed"))
        {
            owner.owner.rigidbody.ResetSpeed(resetYSpd);
        }
    }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUI.BeginChangeCheck();
            serializedObject.UpdateIfRequiredOrScript();
            var value = (EditorTextInput)serializedObject.targetObject;

            EditorGUILayoutExt.ShowScriptField(value);

            if (GUILayout.Button("Submit"))
            {
                value.Submit();
            }

            serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();
        }
Example #13
0
    public override void DrawGUI()
    {
        EventResponder returnedResponder;

        Expanded = TriggerGUILayout.DrawCustomActionInspectorBar(Expanded, Action, out returnedResponder);

        if (!returnedResponder)
        {
            Delete();
            return;
        }
        if (returnedResponder != Action)
        {
            Action = returnedResponder;
        }

        if (Expanded)
        {
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Space(25);
            EditorGUILayout.BeginVertical();

            GUILayout.BeginVertical(GUI.skin.box);

            TriggerAttribute triggerAttribute = TriggerGUILayout.GetTriggerAttribute(Action.GetType());
            if (triggerAttribute != null)
            {
                GUILayout.Label(triggerAttribute.Description, EditorStyles.wordWrappedLabel, GUILayout.ExpandWidth(false));
            }

            EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null);
            GUILayout.Label("Input Parameters");
            EditorGUILayoutExt.EndLabelStyle();

            TriggerGUILayout.DrawSerializedObject(_serializedAction, Action.GetType(), GetScopeVariables());
            EditorGUILayout.Separator();

            GUILayout.EndVertical();

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
    }
Example #14
0
        void DrawObjectFieldGUI(ref string name, ref UnityObject scene)
        {
            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            {
#if !(Unity3 || Unity4_0To4_2)
                GUILayout.BeginHorizontal();
                name = GUILayout.TextField(name, GUILayout.Width(EditorGUIUtility.labelWidth));
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(SceneAsset), true);
#else
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(UnityObject), true);
#endif
                GUILayout.EndHorizontal();
#else
                scene = EditorGUILayoutExt.ObjectField(name, scene, typeof(UnityObject), true);
#endif
            }
            GUILayout.EndVertical();
        }
Example #15
0
        private static void DrawStatus(Platforms platforms, PlatformType selectedPlatform, PlatformConfiguration currentConfiguration, BuildTargetGroup targetGroup)
        {
            using (new Header("Status"))
            {
                EditorGUILayoutExt.LabeledField("Current platform", nameFieldWidth, selectedPlatform, nameFieldWidth);
                EditorGUILayoutExt.LabeledField("Current build target", nameFieldWidth, targetGroup, nameFieldWidth);

                if (targetGroup == BuildTargetGroup.Android)
                {
                    EditorGUILayoutExt.LabeledField("Min Android SDK version", nameFieldWidth, currentConfiguration.AndroidSdkVersion, nameFieldWidth);
                }

                using (new HGroup())
                {
                    EditorGUILayout.LabelField("Change platform", nameFieldWidth);
                    selectedPlatform = (PlatformType)EditorGUILayout.EnumPopup(selectedPlatform, nameFieldWidth);
                    if (selectedPlatform != ProjectConfiguration.Platform)
                    {
                        var nextPlatform = platforms.Configurations[selectedPlatform];
                        if (nextPlatform.IsSupported())
                        {
                            ProjectConfiguration.Platform = nextPlatform.Name;
                            nextPlatform.SwitchTarget();
                        }
                        else
                        {
                            EditorUtility.DisplayDialog(
                                "Juniper",
                                $"The platform {selectedPlatform} is not supported on your current system.",
                                "OK");
                        }
                    }
                }

                using (new EnabledScope(!currentConfiguration.IsActivated()))
                {
                    if (GUILayout.Button("Activate", buttonWidth))
                    {
                        currentConfiguration.Activate();
                    }
                }
            }
        }
Example #16
0
        public override void OnInspectorGUI()
        {
            using (new EditorGUI.ChangeCheckScope())
            {
                serializedObject.Update();

                var value = (Speakable)serializedObject.targetObject;
                EditorGUILayoutExt.ShowScriptField(value);

                PropertyField(serializedObject.FindProperty("playOnAwake"), new GUIContent("Play on Awake"));
                PropertyField(serializedObject.FindProperty("text"), new GUIContent("Text"));

                if (voices == null)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        Popup(VoiceLocaleDropdownLabel, 0, Array.Empty <GUIContent>());
                    }
                }
                else
                {
                    var voiceLanguages = voices
                                         .Select(v => v.Locale)
                                         .Distinct()
                                         .OrderBy(v => v)
                                         .ToArray();

                    var voiceLanguagesLabels = voiceLanguages.ToGUIContents();

                    var selectedLocaleIndex = ArrayUtility.IndexOf(voiceLanguages, value.voiceLanguage);
                    selectedLocaleIndex = Popup(VoiceLocaleDropdownLabel, selectedLocaleIndex, voiceLanguagesLabels);

                    if (selectedLocaleIndex < 0)
                    {
                        using (new EditorGUI.DisabledScope(true))
                        {
                            Popup(VoiceGenderDropdownLabel, 0, Array.Empty <GUIContent>());
                        }
                    }
                    else
                    {
                        var selectedLanguage = voiceLanguages[selectedLocaleIndex];
                        if (selectedLanguage != value.voiceLanguage)
                        {
                            value.voiceLanguage = selectedLanguage;
                            value.voiceGender   = string.Empty;
                            value.voiceName     = string.Empty;
                        }

                        var langVoices = voices
                                         .Where(v => v.Locale == selectedLanguage);

                        var voiceGenders = langVoices
                                           .Select(v => v.Gender)
                                           .Distinct()
                                           .ToArray();

                        var voiceGenderLabels = voiceGenders.ToGUIContents();

                        var selectedGenderIndex = ArrayUtility.IndexOf(voiceGenders, value.voiceGender);
                        selectedGenderIndex = Popup(VoiceGenderDropdownLabel, selectedGenderIndex, voiceGenderLabels);

                        if (selectedGenderIndex < 0)
                        {
                            Popup(VoiceNameDropdownLabel, 0, Array.Empty <GUIContent>());
                        }
                        else
                        {
                            var selectedGender = voiceGenders[selectedGenderIndex];
                            if (selectedGender != value.voiceGender)
                            {
                                value.voiceGender = selectedGender;
                                value.voiceName   = string.Empty;
                            }

                            var gendVoices = langVoices
                                             .Where(v => v.Gender == selectedGender);

                            var voiceNames = gendVoices
                                             .Select(v => v.ShortName)
                                             .ToArray();

                            var voiceNameLabels = voiceNames.ToGUIContents();

                            var selectedNameIndex = ArrayUtility.IndexOf(voiceNames, value.voiceName);
                            selectedNameIndex = Popup(VoiceNameDropdownLabel, selectedNameIndex, voiceNameLabels);
                            if (0 <= selectedNameIndex)
                            {
                                value.voiceName = voiceNames[selectedNameIndex];

                                value.pitch        = Slider("Pitch", value.pitch, -0.1f, 3f);
                                value.speakingRate = Slider("Rate", value.speakingRate, -0.1f, 5f);
                            }
                            else
                            {
                                value.voiceName = string.Empty;
                            }
                        }
                    }
                }

                PropertyField(serializedObject.FindProperty("OnEnd"), new GUIContent("On End Event"));
                serializedObject.ApplyModifiedProperties();
            }
        }
Example #17
0
        // ReSharper disable once UnusedMember.Local
        void OnGUI()
        {
            //Ctrl + w to close
            if (Event.current.Equals(Event.KeyboardEvent("^w")))
            {
                Close();
                GUIUtility.ExitGUI();
            }

            if (obj == null)
            {
                obj        = viewObject;
                viewObject = null;
            }

            obj = EditorGUILayoutExt.ObjectField("Object", obj, typeof(Object), true);

            GUI.enabled = obj != null;

            fullPath         = EditorGUILayout.Toggle("Show Full Paths", fullPath);
            showDepth        = EditorGUILayout.Toggle("Show Depths", showDepth);
            showType         = EditorGUILayout.Toggle("Show Types", showType);
            showStringArrays = EditorGUILayout.Toggle("Show String Arrays", showStringArrays);

#if !(Unity3 || Unity4_0To4_2)
            EditorGUIUtility.labelWidth = fullPath ? 250 : 150;
#endif

            if (GUILayout.Button("Refresh"))
            {
                so = new SerializedObject(obj);
            }

            if (GUILayout.Button("Print"))
            {
                var it   = so.GetIterator();
                var next = it.Next(true);
                while (next)
                {
                    if (it.name == "m_Script")
                    {
                        Debug.Log("Script array hidden for performance reasons");
                        var depth = it.depth;
                        Debug.Log(it.name);
                        while ((next = it.Next(true)) && it.depth > depth || it.name == "Array")
                        {
                        }
                    }

                    if (!next)
                    {
                        break;
                    }

                    Debug.Log(it.depth + " - " + it.propertyPath + " (" + it.propertyType + ")");

                    next = it.Next(true);
                }
            }

            if (obj != null)
            {
                scroll = GUILayout.BeginScrollView(scroll);
                if (so == null || so.targetObject != obj)
                {
                    so = new SerializedObject(obj);
                }

                var count    = 0;
                var iterator = so.GetIterator();
                var hasNext  = iterator.Next(true);
                while (hasNext)
                {
                    if (iterator.name == "m_Script")
                    {
                        GUI.enabled = false;
                        GUILayout.Label("Script array hidden for performance reasons");
                        GUI.enabled = true;
                        var depth = iterator.depth;
                        while ((hasNext = iterator.Next(true)) && iterator.depth > depth || iterator.name == "Array")
                        {
                        }
                    }

                    if (!hasNext)
                    {
                        break;
                    }

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(Util.tabSize * iterator.depth);

                    if (showDepth)
                    {
                        GUILayout.Label(iterator.depth + "", GUILayout.Width(10));
                    }

                    if (showType)
                    {
                        GUILayout.Label(iterator.propertyType + "", GUILayout.Width(50));
                    }
                    try {
#if !UNITY_3_4 && !UNITY_3_3 && !UNITY_3_2 && !UNITY_3_1 && !UNITY_3_0_0 && !UNITY_3_0
                        if (fullPath)
                        {
                            EditorGUILayout.PropertyField(iterator, new GUIContent(iterator.propertyPath), false);
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(iterator, false);
                        }
#else
                        if (fullPath)
                        {
                            EditorGUILayout.PropertyField(iterator, new GUIContent(iterator.propertyPath));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(iterator);
                        }
#endif
                    } catch {
                        /* ignored */
                    }
                    GUILayout.EndHorizontal();

                    hasNext = iterator.Next(iterator.isExpanded);

                    if (count++ > MaxCount)
                    {
                        break;
                    }
                }
                GUILayout.EndScrollView();

                so.ApplyModifiedProperties();
            }
        }
Example #18
0
 public static void DrawProperty(ref AABB2D shape)
 {
     shape.size = EditorGUILayoutExt.Vector2Field("Size", shape.size);
 }
Example #19
0
    public static bool DrawCustomActionInspectorBar(bool expanded, EventResponder responder, out EventResponder newResponder)
    {
        //Event.current.type == EventType.
        EditorGUILayout.BeginHorizontal();

        EditorGUILayoutExt.BeginLabelStyle(12, FontStyle.Bold, new Color(0.45f, 0.45f, 0.45f), null);
        expanded = GUILayout.Button(expanded ? "▼" : "►", GUI.skin.label, GUILayout.ExpandWidth(false)) ? !expanded : expanded;
        bool newEnabled = GUILayout.Toggle(responder.enabled, "", GUILayout.ExpandWidth(false));

        if (newEnabled != responder.enabled)
        {
            responder.enabled = newEnabled;
        }
        EditorGUILayoutExt.BeginLabelStyle(null, null, new Color(1f, 0.72f, 0.72f), null);

        expanded = GUILayout.Button(responder.GetType().Name, GUI.skin.label, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)) ? !expanded : expanded;
        GUILayout.FlexibleSpace();

        EditorGUILayoutExt.EndLabelStyle();
        EditorGUILayoutExt.EndLabelStyle();

        if (GUILayout.Button("▲", GUILayout.ExpandWidth(false)))
        {
            MoveOrderableUp(responder);
        }

        if (GUILayout.Button("▼", GUILayout.ExpandWidth(false)))
        {
            MoveOrderableDown(responder);
        }

        Type eventType = TriggerGUILayout.DrawActionSelector(responder.GetType());

        if (eventType != null)
        {
            if (eventType != responder.GetType())
            {
                GameObject responderGameObject = responder.gameObject;
                int        executionTime       = responder.Ordinal;
                GameObject.DestroyImmediate(responder);
                responder                = (EventResponder)responderGameObject.AddComponent(eventType);
                responder.Ordinal        = executionTime;
                responderGameObject.name = responder.GetType().Name;
            }
        }
        else
        {
            IOrderable next;
            int        time = responder.Ordinal + 1;
            while ((next = GetOrderableAtTime(responder.gameObject.transform.parent.gameObject, time)) != null)
            {
                next.Ordinal -= 1;
                time++;
            }
            GameObject.DestroyImmediate(responder.gameObject);
            responder = null;
        }

        EditorGUILayout.EndHorizontal();

        newResponder = responder;
        return(expanded);
    }
Example #20
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();
            serializedObject.UpdateIfRequiredOrScript();
            var value = (ButtonEvent)serializedObject.targetObject;

            EditorGUILayoutExt.ShowScriptField(value);
            var enumTypes         = value.GetSupportedButtonTypes().ToArray();
            var enumTypeNames     = enumTypes.Select(t => t.FullName).ToArray();
            var enumTypeLabels    = enumTypeNames.ToGUIContents();
            var selectedTypeIndex = ArrayUtility.IndexOf(enumTypeNames, value.buttonTypeName);

            selectedTypeIndex = EditorGUILayout.Popup(ButtonTypeLabel, selectedTypeIndex, enumTypeLabels);
            var destroy = false;

            if (0 <= selectedTypeIndex)
            {
                value.buttonTypeName = enumTypeNames[selectedTypeIndex];
                var enumType           = enumTypes[selectedTypeIndex];
                var enumStrings        = Enum.GetNames(enumType);
                var enumLabels         = enumStrings.ToGUIContents();
                var selectedValueIndex = ArrayUtility.IndexOf(enumStrings, value.buttonValueName);
                selectedValueIndex = EditorGUILayout.Popup(ButtonValueLabel, selectedValueIndex, enumLabels);

                if (0 > selectedValueIndex)
                {
                    value.buttonValueName = null;
                }
                else
                {
                    var buttonValueName = enumStrings[selectedValueIndex];
                    var key             = ButtonEvent.FormatKey(value.buttonTypeName, buttonValueName);
                    var matching        = value.GetComponents <ButtonEvent>()
                                          .Count(e => e.Key == key && e != value);
                    if (matching <= 0)
                    {
                        value.buttonValueName = buttonValueName;
                        value.inputKey        = (KeyCode)EditorGUILayout.EnumPopup(InputKeyLabel, value.inputKey);
                    }
                    else if (EditorUtility.DisplayDialog("Error", $"A ButtonEvent for {key} already exists. Do you want to delete this ButtonEvent? If you keep this ButtonEvent, its Button Value will be reverted to its previous value.", "Delete", "Keep"))
                    {
                        destroy = true;
                    }
                }
            }

            if (destroy)
            {
                value.DestroyImmediate();
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty(FIELD_ONDOWN));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(FIELD_ONCLICK));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(FIELD_ONDOUBLECLICK));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(FIELD_ONLONGPRESS));
                EditorGUILayout.PropertyField(serializedObject.FindProperty(FIELD_ONUP));
            }

            serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();
        }
Example #21
0
 public static void DrawProperty(ref Circle shape)
 {
     shape.radius = EditorGUILayoutExt.FloatField("Radius", shape.radius);
 }
Example #22
0
    public override void DrawGUI()
    {
        EventSender returnedSender;

        Expanded = TriggerGUILayout.DrawCustomEventInspectorBar(Expanded, _gameObject, out returnedSender);
        if (Sender != returnedSender)
        {
            Sender = returnedSender;
        }

        if (Sender == null)
        {
            return;
        }

        if (Expanded)
        {
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Space(25);
            EditorGUILayout.BeginVertical();

            GUILayout.BeginVertical(GUI.skin.box);

            TriggerAttribute triggerAttribute = TriggerGUILayout.GetTriggerAttribute(Sender.GetType());
            if (triggerAttribute != null)
            {
                GUILayout.Label(triggerAttribute.Description, EditorStyles.wordWrappedLabel, GUILayout.ExpandWidth(false));
            }

            if (_serializedEvent.GetIterator().CountRemaining() > 1)
            {
                EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null);
                GUILayout.Label("Input Parameters");
                EditorGUILayoutExt.EndLabelStyle();
            }
            TriggerGUILayout.DrawSerializedObject(_serializedEvent, Sender.GetType(), Context.GlobalSymbolTable.Variables);


            if (Sender.GetOutputParameterDeclarations().Count > 0)
            {
                EditorGUILayout.Separator();
                EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null);
                GUILayout.Label("Output Parameters");
                EditorGUILayoutExt.EndLabelStyle();

                foreach (var v in Sender.GetOutputParameterDeclarations())
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(15);
                    GUILayout.Label(v.Name + " (" + v.Type.Name + ")", GUILayout.ExpandWidth(false));
                    if (!string.IsNullOrEmpty(v.Description))
                    {
                        GUILayout.Label(v.Description);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box("", GUILayout.Width(300), GUILayout.Height(1));
            EditorGUILayout.EndHorizontal();

            TriggerGUILayout.DrawAddFilterSelector(Sender.gameObject, Context.Refresh);
            TriggerGUILayout.DrawAddActionSelector(Sender.gameObject, Context.Refresh);

            EditorGUILayout.Separator();
            GUILayout.EndVertical();

            EditorGUILayout.Separator();

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
    }
Example #23
0
        // ReSharper disable once UnusedMember.Local
        void OnGUI()
        {
            //Ctrl + w to close
            if (Event.current.Equals(Event.KeyboardEvent("^w")))
            {
                Close();
                GUIUtility.ExitGUI();
            }

            const string label   = "Frame Time (ms)";
            const string tooltip = "Time between yields when processing big scenes. Bigger is faster, but will slow down the UI";

            frameTime = EditorGUILayout.IntSlider(new GUIContent(label, tooltip), frameTime, 1, 1000);
            UniMergeWindow.frameTimeTicks = frameTime * 10000;
            GUILayout.Label("To change these values, set them in UniMergeConfig.cs");
            EditorGUILayout.LabelField("Default Skin", DefaultGuiSkinFilename);
            EditorGUILayout.LabelField("Dark Skin", DarkGuiSkinFilename);
            EditorGUILayout.LabelField("Plugin Path", DefaultPath);
            EditorGUILayout.LabelField("List Style Name", ListStyleName);
            EditorGUILayout.LabelField("List Alt Style Name", ListAltStyleName);
            EditorGUILayout.LabelField("Conflict Suffix", ConflictSuffix);

            GUILayout.Label(new GUIContent(
                                "Note: In order to save your changes you must make\nsome change to the skin in the editor.",
                                "This is because modifying the skin via script doesn't set it \"dirty\""));

            scroll = EditorGUILayout.BeginScrollView(scroll);
            var defaultSkin =
                AssetDatabase.LoadAssetAtPath(DefaultPath + "/" + DefaultGuiSkinFilename, typeof(GUISkin)) as GUISkin;

            if (defaultSkin)
            {
                if (defaultSkin.customStyles.Length < 4)
                {
                    var newStyles = new GUIStyle[4];
                    defaultSkin.customStyles.CopyTo(newStyles, 0);
                    defaultSkin.customStyles = newStyles;
                }
                for (var i = 0; i < defaultSkin.customStyles.Length; i++)
                {
                    if (defaultSkin.customStyles[i] == null)
                    {
                        defaultSkin.customStyles[i] = new GUIStyle();
                    }
                }
                defaultSkin.customStyles[0].name = ListStyleName;
                defaultSkin.customStyles[1].name = ListAltStyleName;
                defaultSkin.customStyles[2].name = ListStyleName + ConflictSuffix;
                defaultSkin.customStyles[3].name = ListAltStyleName + ConflictSuffix;
                GUILayout.Label("Default Skin background colors");
                defaultSkin.customStyles[0].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName,
                                                                                                          defaultSkin.customStyles[0].normal.background, typeof(Texture2D), false);
                defaultSkin.customStyles[1].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName,
                                                                                                          defaultSkin.customStyles[1].normal.background, typeof(Texture2D), false);
                defaultSkin.customStyles[2].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName + ConflictSuffix,
                                                              defaultSkin.customStyles[2].normal.background, typeof(Texture2D), false);
                defaultSkin.customStyles[3].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName + ConflictSuffix,
                                                              defaultSkin.customStyles[3].normal.background, typeof(Texture2D), false);
            }
            else
            {
                GUILayout.Label("<color=red>Oops! No Light Skin found!</color>");
            }

            var darkSkin = AssetDatabase.LoadAssetAtPath(DefaultPath + "/" + DarkGuiSkinFilename, typeof(GUISkin)) as GUISkin;

            if (darkSkin)
            {
                if (darkSkin.customStyles.Length < 4)
                {
                    var newStyles = new GUIStyle[4];
                    darkSkin.customStyles.CopyTo(newStyles, 0);
                    darkSkin.customStyles = newStyles;
                }
                for (var i = 0; i < darkSkin.customStyles.Length; i++)
                {
                    if (darkSkin.customStyles[i] == null)
                    {
                        darkSkin.customStyles[i] = new GUIStyle();
                    }
                }
                darkSkin.customStyles[0].name = ListStyleName;
                darkSkin.customStyles[1].name = ListAltStyleName;
                darkSkin.customStyles[2].name = ListStyleName + ConflictSuffix;
                darkSkin.customStyles[3].name = ListAltStyleName + ConflictSuffix;
                GUILayout.Label("Dark Skin background colors");
                darkSkin.customStyles[0].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName,
                                                                                                       darkSkin.customStyles[0].normal.background, typeof(Texture2D), false);
                darkSkin.customStyles[1].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName,
                                                                                                       darkSkin.customStyles[1].normal.background, typeof(Texture2D), false);
                darkSkin.customStyles[2].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName + ConflictSuffix,
                                                              darkSkin.customStyles[2].normal.background, typeof(Texture2D), false);
                darkSkin.customStyles[3].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName + ConflictSuffix,
                                                              darkSkin.customStyles[3].normal.background, typeof(Texture2D), false);
            }
            else
            {
                GUILayout.Label("<color=red>Oops! No Dark Skin found!</color>");
            }
            EditorGUILayout.EndScrollView();
        }
Example #24
0
        // ReSharper disable once UnusedMember.Local
        void OnGUI()
        {
            if (InitGUI())
            {
                return;
            }

            /*
             * BEGIN GUI
             */

            var root = this.root;

            GUILayout.BeginHorizontal();
            {
                /*
                 * Options
                 */
                GUILayout.BeginVertical();
                {
                    const string tooltip = "When enabled, copying GameObjects or Components will search for references"
                                           + " to them and try to set them.  Disable if you do not want this behavior or if the window "
                                           + "locks up on copy (too many objects)";
                    deepCopy = EditorGUILayout.Toggle(new GUIContent("Deep Copy", tooltip), deepCopy);
                }

                {
                    const string tooltip = "When enabled, non-obvious events (like deep copy reference setting) will be logged";
                    log = EditorGUILayout.Toggle(new GUIContent("Log", tooltip), log);
                }

                {
                    const string tooltip = "When disabled, attributes will not be included in comparison algorithm."
                                           + "  To choose which components are included, use the drop-downs to the right.";
                    compareAttrs = EditorGUILayout.Toggle(new GUIContent("Compare Attributes", tooltip), compareAttrs);
                }

                GUI.enabled = !IsUpdating();
                if (GUILayout.Button("Expand Differences"))
                {
                    updateCount    = 0;
                    totalUpdateNum = GameObjectHelper.GetCount(false, root);
                    updateType     = RefreshType.Expanding;
                    update         = root.ExpandDiffs();
                }

                //GUILayout.BeginHorizontal();
                //if (GUILayout.Button("Prev Difference")) {
                //	PrevDifference();
                //}
                //if (GUILayout.Button("Next Difference")) {
                //	NextDifference();
                //}
                //GUILayout.EndHorizontal();

                if (GUILayout.Button("Refresh"))
                {
                    update = root.BubbleRefresh();
                }

                GUI.enabled = true;

                DrawRowHeight();

                GUILayout.Space(10);                 //Padding between controls and merge space
                GUILayout.EndVertical();

                /*
                 * Comparison Filters
                 */
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();

#if !Unity3
                GUILayout.FlexibleSpace();
#endif

#if Unity3 //TODO: Better masking for U3
                GUILayout.BeginVertical();
                GUILayout.Label("Enter a list of component types to exclude, separated by commas");
                filters = EditorGUILayout.TextField("Filters", filters);
                if (filters != lastFilters)
                {
                    ParseFilters();
                }
                lastFilters = filters;
                string filt = "Filtering: ";
                if (filterTypes.Count > 0)
                {
                    foreach (System.Type bad in filterTypes)
                    {
                        filt += bad.Name + ", ";
                    }
                    GUILayout.Label(filt.Substring(0, filt.Length - 2));
                }
                string err = "Sorry, the following types are invalid: ";
                if (badTypes.Count > 0)
                {
                    foreach (string bad in badTypes)
                    {
                        err += bad + ", ";
                    }
                    GUILayout.Label(err.Substring(0, err.Length - 2));
                }
                string cerr = "Sorry, the following types aren't components: ";
                if (notComponents.Count > 0)
                {
                    foreach (string bad in notComponents)
                    {
                        cerr += bad + ", ";
                    }
                    GUILayout.Label(cerr.Substring(0, cerr.Length - 2));
                }
                GUILayout.EndVertical();
#else
                GUILayout.Label(new GUIContent("Comparison Filters",
                                               "Select which components should be included in"
                                               + " the comparison. You can't filter more"
                                               + " than 31 things :("));
                if (componentTypeStrings != null)
                {
                    var mask = typeMask;
                    for (var i = 0; i < componentTypeStrings.Length; i++)
                    {
                        mask[i] = EditorGUILayout.MaskField(mask[i], componentTypeStrings[i], Width75);
                        if (i % 3 == 2)
                        {
                            GUILayout.EndHorizontal();
                            GUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                        }
                    }
                }
#endif
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            var colWdithOption = GUILayout.Width(colWidth);
            var mine           = root.mine;
            var theirs         = root.theirs;
            var lastVal        = mine;
            GUILayout.BeginVertical(colWdithOption);
#if !(Unity3 || Unity4_0To4_2)
            GUILayout.BeginHorizontal();
            var labelWidthOption = GUILayout.Width(EditorGUIUtility.labelWidth);
            mineName = GUILayout.TextField(mineName, labelWidthOption);
            mine     = (GameObject)EditorGUILayoutExt.ObjectField(mine, typeof(GameObject), true);
            GUILayout.EndHorizontal();
#else
            mine = (GameObject)EditorGUILayoutExt.ObjectField(mineName, mine, typeof(GameObject), true);
#endif
            if (mine != lastVal)
            {
                root.SetGameObjects(mine, theirs);
                if (!blockRefresh)
                {
                    update = Refresh();
                }
            }

            lastVal = theirs;
            GUILayout.EndVertical();
            GUILayout.Space(UniMergeConfig.DoubleMidWidth);
            GUILayout.BeginVertical(colWdithOption);
#if !(Unity3 || Unity4_0To4_2)
            GUILayout.BeginHorizontal();
            theirName = GUILayout.TextField(theirName, labelWidthOption);
            theirs    = (GameObject)EditorGUILayoutExt.ObjectField(theirs, typeof(GameObject), true);
            GUILayout.EndHorizontal();
#else
            theirs = (GameObject)EditorGUILayoutExt.ObjectField(theirName, theirs, typeof(GameObject), true);
#endif
            if (theirs != lastVal)
            {
                root.SetGameObjects(mine, theirs);
                if (!blockRefresh)
                {
                    update = Refresh();
                }
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

#if !(Unity3 || Unity4_0To4_2)
            EditorGUIUtility.labelWidth = 75;             //Make labels just a bit tighter for compactness
#endif
            if (mine && theirs)
            {
                CustomScroll(draw);
            }

            ProgressBar();
        }
Example #25
0
    public override void DrawGUI()
    {
        EventFilter returnedFilter;

        Expanded = TriggerGUILayout.DrawCustomFilterInspectorBar(Expanded, Filter, out returnedFilter);

        if (!returnedFilter)
        {
            foreach (Variable var in _outputVariables.Values)
            {
                ScriptableObject.DestroyImmediate(var);
            }
            Delete();
            return;
        }
        Filter = returnedFilter;

        if (Expanded)
        {
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Space(25);
            EditorGUILayout.BeginVertical();

            GUILayout.BeginVertical(GUI.skin.box);

            TriggerAttribute triggerAttribute = TriggerGUILayout.GetTriggerAttribute(Filter.GetType());
            if (triggerAttribute != null)
            {
                GUILayout.Label(triggerAttribute.Description, EditorStyles.wordWrappedLabel, GUILayout.ExpandWidth(false));
            }

            EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null);
            GUILayout.Label("Input Parameters");
            EditorGUILayoutExt.EndLabelStyle();

            TriggerGUILayout.DrawSerializedObject(_serializedFilter, Filter.GetType(), Parent.GetScopeVariables());

            EditorGUILayout.Separator();

            EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null);
            GUILayout.Label("Output Parameters");
            EditorGUILayoutExt.EndLabelStyle();

            foreach (var v in Filter.GetOutputParameterDeclarations())
            {
                GUILayout.Label(v.Name, GUILayout.ExpandWidth(false));
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box("", GUILayout.Width(300), GUILayout.Height(1));
            EditorGUILayout.EndHorizontal();

            TriggerGUILayout.DrawAddFilterSelector(Filter.gameObject, Context.Refresh);
            TriggerGUILayout.DrawAddActionSelector(Filter.gameObject, Context.Refresh);

            EditorGUILayout.Separator();

            GUILayout.EndVertical();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
    }
Example #26
0
        void OnGUI()
        {
            if (_testRunner == null)
            {
                _testRunner = new TestRunner();
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Refresh", EditorStylesExt.ButtonLeft))
            {
                _testRunner = new TestRunner();
            }

            if (GUILayout.Button("Run All", EditorStylesExt.ButtonMiddle))
            {
                foreach (TestFixtureDefinition fixture in _testRunner.TestFixtures)
                {
                    fixture.Run();
                }
            }
            if (GUILayout.Button("Clear Results", EditorStylesExt.ButtonRight))
            {
                foreach (TestFixtureDefinition fixture in _testRunner.TestFixtures)
                {
                    fixture.ClearResults();
                }
            }
            GUILayout.EndHorizontal();

            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
            foreach (TestFixtureDefinition fixture in _testRunner.TestFixtures)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Run", EditorStylesExt.LockedHeaderButton, GUILayout.ExpandWidth(false)))
                {
                    fixture.Run();
                    Repaint();
                }
                TestStatus fixtureTestStatus = fixture.TestStatus;

                Color?fixtureLabelColor = null;
                if (fixtureTestStatus == TestStatus.Passed)
                {
                    fixtureLabelColor = EditorStylesExt.EditorGreen;
                }
                if (fixtureTestStatus == TestStatus.Failed)
                {
                    fixtureLabelColor = EditorStylesExt.EditorRed;
                }
                EditorGUILayoutExt.BeginStyle(GUI.skin.label, 12, FontStyle.Bold, fixtureLabelColor, null);
                GUILayout.Label(fixture.Name, GUI.skin.label, GUILayout.ExpandWidth(false));
                EditorGUILayoutExt.EndStyle();
                //
                GUILayout.Label("(" + fixture.Tests.Count + " tests)");

                GUILayout.EndHorizontal();

                if (fixtureTestStatus != TestStatus.Passed)
                {
                    GUILayout.BeginVertical(GUI.skin.box);
                    int index = 0;
                    foreach (TestDefinition test in fixture.Tests)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        Rect statusRect = GUILayoutUtility.GetRect(new GUIContent("__"), GUI.skin.label, GUILayout.ExpandWidth(false));

                        switch (test.Result.TestStatus)
                        {
                        case TestStatus.Failed:
                            EditorGUILayoutExt.BeginStyle(GUI.skin.label, null, FontStyle.Bold, EditorStylesExt.EditorRed, null);
                            GUI.Label(statusRect, "X");
                            EditorGUILayoutExt.EndStyle();
                            break;

                        case TestStatus.Passed:
                            EditorGUILayoutExt.BeginStyle(GUI.skin.label, null, FontStyle.Bold, EditorStylesExt.EditorGreen, null);
                            GUI.Label(statusRect, EditorStylesExt.Checkmark);
                            EditorGUILayoutExt.EndStyle();
                            break;

                        case TestStatus.Unknown:
                            EditorGUILayoutExt.BeginStyle(GUI.skin.label, null, FontStyle.Bold, EditorStylesExt.EditorGray, null);
                            GUI.Label(statusRect, "?");
                            EditorGUILayoutExt.EndStyle();
                            break;
                        }

                        if (GUILayout.Button("Run", EditorStylesExt.ToolbarButton, GUILayout.ExpandWidth(false)))
                        {
                            fixture.RunSingle(index);
                            Repaint();
                        }
                        GUILayout.Label(test.TestName, EditorStylesExt.ToolbarButton, GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();


                        if (test.Result.TestStatus == TestStatus.Failed)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(10);
                            GUILayout.TextArea(test.Result.ResultMessage);
                            GUILayout.EndHorizontal();
                        }



                        index++;
                        GUILayout.Space(3);
                    }

                    GUILayout.EndVertical();
                }
                GUILayout.Space(10);
            }

            GUILayout.EndScrollView();
        }