From cb81d573b112198af3853764b0add74b3da1d1de Mon Sep 17 00:00:00 2001 From: kkjamie Date: Wed, 8 Nov 2017 09:29:13 +0000 Subject: [PATCH 1/4] Made EditorGUILayoutHelpers partial so we can add to it --- Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs b/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs index d889c0c..f3e3fc6 100644 --- a/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs +++ b/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs @@ -5,7 +5,7 @@ namespace DUCK.Utils.Editor.EditorGUIHelpers { - public static class EditorGUILayoutHelpers + public static partial class EditorGUILayoutHelpers { private static readonly Dictionary> drawerFunctions = new Dictionary> From 805e542f42832c6434c1ec594442037ad9d959a1 Mon Sep 17 00:00:00 2001 From: kkjamie Date: Wed, 8 Nov 2017 09:29:36 +0000 Subject: [PATCH 2/4] Use overload to remove obsolete method warning --- Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs b/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs index f3e3fc6..3fa9116 100644 --- a/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs +++ b/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs @@ -43,7 +43,7 @@ public static object FieldByType(string label, object obj, Type type) // special case for object fields if (typeof(UnityEngine.Object).IsAssignableFrom(type)) { - return EditorGUILayout.ObjectField(label, (UnityEngine.Object) obj, type); + return EditorGUILayout.ObjectField(label, (UnityEngine.Object) obj, type, true); } // check we can deal with this type of field From 905a72a1ba6f7d25fdd4f45f1247d83db81fb264 Mon Sep 17 00:00:00 2001 From: kkjamie Date: Wed, 8 Nov 2017 09:29:58 +0000 Subject: [PATCH 3/4] Added OptionSelector to EditorGUILayoutHelpers --- Utils/Editor/EditorGUIHelpers/OptionSelector.cs | 15 +++++++++++++++ .../EditorGUIHelpers/OptionSelector.cs.meta | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 Utils/Editor/EditorGUIHelpers/OptionSelector.cs create mode 100644 Utils/Editor/EditorGUIHelpers/OptionSelector.cs.meta diff --git a/Utils/Editor/EditorGUIHelpers/OptionSelector.cs b/Utils/Editor/EditorGUIHelpers/OptionSelector.cs new file mode 100644 index 0000000..4038e07 --- /dev/null +++ b/Utils/Editor/EditorGUIHelpers/OptionSelector.cs @@ -0,0 +1,15 @@ +using System; +using UnityEditor; + +namespace DUCK.Utils.Editor.EditorGUIHelpers +{ + public static partial class EditorGUILayoutHelpers + { + public static string OptionSelectorField(string label, string value, string[] options) + { + var index = Array.IndexOf(options, value); + var selectedIndex = EditorGUILayout.Popup(label, index, options); + return selectedIndex >= 0 ? options[selectedIndex] : ""; + } + } +} \ No newline at end of file diff --git a/Utils/Editor/EditorGUIHelpers/OptionSelector.cs.meta b/Utils/Editor/EditorGUIHelpers/OptionSelector.cs.meta new file mode 100644 index 0000000..8b7f548 --- /dev/null +++ b/Utils/Editor/EditorGUIHelpers/OptionSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0dfc73d3505e4188a3bb24b7010baac6 +timeCreated: 1509968839 \ No newline at end of file From 44ef9aaf2f394aad1a67f4643b4451851d4640bf Mon Sep 17 00:00:00 2001 From: kkjamie Date: Wed, 8 Nov 2017 09:30:56 +0000 Subject: [PATCH 4/4] Rename file containing partial class --- .../{EditorGUILayoutHelpers.cs => DrawFieldByTypes.cs} | 0 .../{EditorGUILayoutHelpers.cs.meta => DrawFieldByTypes.cs.meta} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Utils/Editor/EditorGUIHelpers/{EditorGUILayoutHelpers.cs => DrawFieldByTypes.cs} (100%) rename Utils/Editor/EditorGUIHelpers/{EditorGUILayoutHelpers.cs.meta => DrawFieldByTypes.cs.meta} (100%) diff --git a/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs b/Utils/Editor/EditorGUIHelpers/DrawFieldByTypes.cs similarity index 100% rename from Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs rename to Utils/Editor/EditorGUIHelpers/DrawFieldByTypes.cs diff --git a/Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs.meta b/Utils/Editor/EditorGUIHelpers/DrawFieldByTypes.cs.meta similarity index 100% rename from Utils/Editor/EditorGUIHelpers/EditorGUILayoutHelpers.cs.meta rename to Utils/Editor/EditorGUIHelpers/DrawFieldByTypes.cs.meta