Skip to content

Instantly share code, notes, and snippets.

@uzzu
Last active December 18, 2015 08:29
Show Gist options
  • Save uzzu/5754333 to your computer and use it in GitHub Desktop.
Save uzzu/5754333 to your computer and use it in GitHub Desktop.
UnityEditor.CustomEditor使用時のプリミティブ配列地獄からの脱却
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()
{
}
}
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