public override void OnEnable() { bsl = target as BiomeSwitchList; switchDatas = bsl.switchDatas; reorderableSwitchDataList = new ReorderableList(bsl.switchDatas, typeof(BiomeSwitchData), true, true, true, true); reorderableSwitchDataList.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 4; //padding reorderableSwitchDataList.drawElementCallback = DrawElementCallback; reorderableSwitchDataList.drawHeaderCallback = (rect) => { EditorGUI.LabelField(rect, "switches"); }; reorderableSwitchDataList.onReorderCallback += (ReorderableList l) => { if (bsl.OnBiomeDataReordered != null) { bsl.OnBiomeDataReordered(); } }; reorderableSwitchDataList.onAddCallback += (ReorderableList l) => { BiomeSwitchData bsd = new BiomeSwitchData(bsl.sampler, bsl.samplerName); BiomeSwitchData lastSwitch = switchDatas.Last(); bsd.min = lastSwitch.min + (lastSwitch.max - lastSwitch.min) / 2; switchDatas.Add(bsd); if (bsl.OnBiomeDataAdded != null) { bsl.OnBiomeDataAdded(bsd); } }; reorderableSwitchDataList.onRemoveCallback += (ReorderableList l) => { if (switchDatas.Count > 1) { switchDatas.RemoveAt(l.index); if (bsl.OnBiomeDataRemoved != null) { bsl.OnBiomeDataRemoved(); } } }; //add at least one biome switch: if (switchDatas.Count == 0) { switchDatas.Add(new BiomeSwitchData(bsl.sampler, bsl.samplerName)); } }