Hoge[] hoges をEditorWindowで出したい。
using UnityEngine;
using UnityEditor;
public class MyEditor : EditorWindow
{
[System.Serializable] // 必須.
class Hoge
{
public bool boolHoge;
public int intHoge;
public string strHoge;
}
[SerializeField] // 必須.
Hoge[] hoges = new Hoge[]
{
new Hoge
{
boolHoge = false,
intHoge = 1,
strHoge = "2",
},
}
void OnGUI ()
{
ScriptableObject target = this;
SerializedObject so = new SerializedObject(target);
// 上のプロパティを文字列で指定する.
SerializedProperty stringsProperty = so.FindProperty("hoges");
// trueは子の表示.
EditorGUILayout.PropertyField(stringsProperty, true);
// 変更の記憶.
so.ApplyModifiedProperties();
// 実行はできるが、ダメ.
// foreachだとiterateしたもの自身に代入になるのでそもそもダメ.
// for(var i=0; i < this.hoges.Length; i++)
// {
// this.hoges[i] = EditorGUILayout.ObjectField("ラベル", this.drops[i], typeof(Hoge), true) as Hoge;
// }
}
}