Question by
atomic99 · Jun 24, 2017 at 11:49 AM ·
c#listeditor-scriptingserialization
Set a List Property with EditorScripting
Hey I have a quick Question about Editor Scripting in Unity. I didnt found the right solution for me on the forums. My Problem is that I have a Component with a List Property where I store my different settings for the difficulties. In my editor script I have a own List property where i first set up everything and then i want to match these two lists. But with the current code it doesnt work. Would be great if somebody could help
Component:
[System.Serializable]
public class Generator : MonoBehaviour
{
public List<Difficultie> difficulties;
//A lot of code
}
Difficultie:
public class Difficultie {
public string difName;
public int maxRoomHeigt = 5;
public int minRoomHeigt = 2;
public int maxRoomWidth = 5;
public int minRoomWidth = 2;
public int maxDoorsPerRooms = 3;
public int minDoorsPerRooms = 1;
public float ChestPercentage = 0.5f;
public bool deleteDeadEnds=false;
}
ComponentEditor:
[CustomEditor(typeof(Generator))]
public class GeneratorScriptEditor : Editor
{
Generator generator;
List<Difficultie> difficulties = new List<Difficultie>();
public override void OnInspectorGUI()
{
generator = (Generator)target
target.difficulties = difficulties;
}
//More Code where I add elements to the List
}
Comment