Skip to content

Instantly share code, notes, and snippets.

@Suzeep
Last active December 27, 2015 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suzeep/7257058 to your computer and use it in GitHub Desktop.
Save Suzeep/7257058 to your computer and use it in GitHub Desktop.
カスタムインスペクタに配列を表示するサンプルコード。
using UnityEngine;
using System.Collections;
public class Sample : MonoBehaviour
{
// member
public int m_Count;
public int[] m_CountArray = new int[ 4 ];
public float m_DeltaTime;
}
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor( typeof(Sample) )]
public class SampleInspector : Editor
{
// OnInspectorGUI
public override void OnInspectorGUI()
{
// update
this.serializedObject.Update();
var sample = this.target as Sample;
{
// count
sample.m_Count = EditorGUILayout.IntField( "Count", sample.m_Count );
// array count
drawArrayProperty( "m_CountArray" );
// delta time
sample.m_DeltaTime = EditorGUILayout.FloatField( "DeltaTime", sample.m_DeltaTime );
}
}
// draw array property
private void drawArrayProperty( string prop_name )
{
EditorGUIUtility.LookLikeInspector();
SerializedProperty prop = this.serializedObject.FindProperty( prop_name );
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField( prop, true );
if( EditorGUI.EndChangeCheck() ){
this.serializedObject.ApplyModifiedProperties();
}
EditorGUIUtility.LookLikeControls();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment