浏览代码

Fixing LabelingConfigurationEditor refresh and save bugs

/main
Jon Hogins 5 年前
当前提交
03956206
共有 1 个文件被更改,包括 21 次插入7 次删除
  1. 28
      com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs

28
com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs


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();
}
}
正在加载...
取消
保存