Last active
December 18, 2015 08:29
-
-
Save uzzu/5754333 to your computer and use it in GitHub Desktop.
UnityEditor.CustomEditor使用時のプリミティブ配列地獄からの脱却
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class HogeComponent : MonoBehaviour | |
{ | |
public enum Fuga | |
{ | |
Foo, | |
Bar, | |
Baz | |
} | |
public int SelectedIndex; | |
public List<string> Selections = new List<string>(Enum.GetNames(typeof(HogeComponent.Fuga))); | |
void Start() | |
{ | |
} | |
void Update() | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
[CustomEditor(typeof(HogeComponent))] | |
public class HogeComponentInspector : Editor | |
{ | |
public override void OnInspectorGUI() | |
{ | |
HogeComponent hoge = target as HogeComponent; | |
GUILayout.Label("Hoge selections"); | |
hoge.SelectedIndex = GUILayout.SelectionGrid(controller.SelectedIndex, hoge.Selections.ToArray(), 1, "toggle"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment