|
|
|
|
|
|
void OnRemove(ReorderableList list) |
|
|
|
{ |
|
|
|
if (list.index != -1) |
|
|
|
config.LabelingConfigurations.RemoveAt(list.index); |
|
|
|
list.serializedProperty.DeleteArrayElementAtIndex(list.index); |
|
|
|
|
|
|
|
this.serializedObject.ApplyModifiedProperties(); |
|
|
|
EditorUtility.SetDirty(target); |
|
|
|
} |
|
|
|
|
|
|
|
LabelingConfiguration config => (LabelingConfiguration)this.target; |
|
|
|
|
|
|
config.LabelingConfigurations.Add(new LabelingConfigurationEntry("", 0)); |
|
|
|
var index = list.serializedProperty.arraySize; |
|
|
|
list.serializedProperty.InsertArrayElementAtIndex(index); |
|
|
|
var element = list.serializedProperty.GetArrayElementAtIndex(index); |
|
|
|
var labelProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.label)); |
|
|
|
labelProperty.stringValue = ""; |
|
|
|
var valueProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.value)); |
|
|
|
valueProperty.intValue = 0; |
|
|
|
serializedObject.ApplyModifiedProperties(); |
|
|
|
EditorUtility.SetDirty(target); |
|
|
|
var entry = config.LabelingConfigurations[index]; |
|
|
|
var element = m_LabelsList.serializedProperty.GetArrayElementAtIndex(index); |
|
|
|
var labelProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.label)); |
|
|
|
var valueProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.value)); |
|
|
|
var newLabel = EditorGUI.TextField(contentRect, nameof(LabelingConfigurationEntry.label), entry.label); |
|
|
|
var newLabel = EditorGUI.TextField(contentRect, nameof(LabelingConfigurationEntry.label), labelProperty.stringValue); |
|
|
|
config.LabelingConfigurations[index] = new LabelingConfigurationEntry(newLabel, entry.value); |
|
|
|
labelProperty.stringValue = newLabel; |
|
|
|
var newValue = EditorGUI.IntField(contentRect, nameof(LabelingConfigurationEntry.value), entry.value); |
|
|
|
var newValue = EditorGUI.IntField(contentRect, nameof(LabelingConfigurationEntry.value), valueProperty.intValue); |
|
|
|
config.LabelingConfigurations[index] = new LabelingConfigurationEntry(entry.label, newValue); |
|
|
|
valueProperty.intValue = newValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
this.serializedObject.ApplyModifiedProperties(); |
|
|
|
} |
|
|
|
} |