static Func <IList> drawEditActions(IList list, Type elementType, int index) { if (EntitasEditorLayout.MiniButtonLeft("↑")) { if (index > 0) { return(() => { var otherIndex = index - 1; var other = list[otherIndex]; list[otherIndex] = list[index]; list[index] = other; return list; }); } } if (EntitasEditorLayout.MiniButtonMid("↓")) { if (index < list.Count - 1) { return(() => { var otherIndex = index + 1; var other = list[otherIndex]; list[otherIndex] = list[index]; list[index] = other; return list; }); } } if (EntitasEditorLayout.MiniButtonMid("+")) { object defaultValue; if (EntityDrawer.CreateDefault(elementType, out defaultValue)) { var insertAt = index + 1; return(() => { list.Insert(insertAt, defaultValue); return list; }); } } if (EntitasEditorLayout.MiniButtonRight("-")) { var removeAt = index; return(() => { list.RemoveAt(removeAt); return list; }); } return(null); }
static Func <Array> drawEditActions(Array array, Type elementType, int index) { if (EntitasEditorLayout.MiniButtonLeft("↑")) { if (index > 0) { return(() => { var otherIndex = index - 1; var other = array.GetValue(otherIndex); array.SetValue(array.GetValue(index), otherIndex); array.SetValue(other, index); return array; }); } } if (EntitasEditorLayout.MiniButtonMid("↓")) { if (index < array.Length - 1) { return(() => { var otherIndex = index + 1; var other = array.GetValue(otherIndex); array.SetValue(array.GetValue(index), otherIndex); array.SetValue(other, index); return array; }); } } if (EntitasEditorLayout.MiniButtonMid("+")) { object defaultValue; if (EntityDrawer.CreateDefault(elementType, out defaultValue)) { return(() => arrayInsertAt(array, elementType, defaultValue, index + 1)); } } if (EntitasEditorLayout.MiniButtonRight("-")) { return(() => arrayRemoveAt(array, elementType, index)); } return(null); }