Skip to content

Commit

Permalink
Merge pull request #4 from dubit/dev_options_selector
Browse files Browse the repository at this point in the history
EditorGUILayoutHelpers: Draw Options Selector
  • Loading branch information
kkjamie authored Nov 10, 2017
2 parents 397b060 + e80ca9d commit c81b2f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DUCK.Utils.Editor.EditorGUIHelpers
{
public static class EditorGUILayoutHelpers
public static partial class EditorGUILayoutHelpers
{
private static readonly Dictionary<Type, Func<string, object, object>> drawerFunctions =
new Dictionary<Type, Func<string, object, object>>
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions Utils/Editor/EditorGUIHelpers/OptionSelector.cs
Original file line number Diff line number Diff line change
@@ -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] : "";
}
}
}
3 changes: 3 additions & 0 deletions Utils/Editor/EditorGUIHelpers/OptionSelector.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c81b2f8

Please sign in to comment.