Can any1 make an example of editor GUI for this kind of code?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class lists : MonoBehaviour
{
public List<SomeList> theList = new List<SomeList>();
}
[System.Serializable]
public class SomeList
{
public GameObject[] objects;
public float someFloat;
}
nbg_yalta:
Can any1 make an example of editor GUI for this kind of code?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class lists : MonoBehaviour
{
public List<SomeList> theList = new List<SomeList>();
}
[System.Serializable]
public class SomeList
{
public GameObject[] objects;
public float someFloat;
}
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class YourEditorWindow : EditorWindow
{
public List<SomeList> TheList = new List<SomeList>();
[MenuItem("Window/YourEditorWindow")]
static void Init()
{
/**
* Instantiate window
* */
YourEditorWindow window = (YourEditorWindow) GetWindow(typeof(YourEditorWindow), false, "Your window");
//window.autoRepaintOnSceneChange = true;
//window.minSize = new Vector2(300, 200);
//window.wantsMouseMove = true;
window.Show();
var item = new SomeList();
item.someFloat = 10.3f;
window.TheList.Add(item);
}
void OnGUI() {
foreach (SomeList item in TheList)
{
GUILayout.Label(item.someFloat.ToString());
foreach (GameObject go in item.objects )
{
GUILayout.Button(go.name);
}
}
}
}
public class SomeList
{
public GameObject[] objects = new GameObject[]{};
public float someFloat;
}