浏览代码

implementing label config editor

/main
Mohsen Kamalzadeh 4 年前
当前提交
7ea6908e
共有 19 个文件被更改,包括 1024 次插入145 次删除
  1. 278
      com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor.cs
  2. 2
      com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor.cs.meta
  3. 52
      com.unity.perception/Editor/GroundTruth/LabelingEditor.cs
  4. 41
      com.unity.perception/Editor/GroundTruth/Uss/Styles.uss
  5. 14
      com.unity.perception/Editor/GroundTruth/Uxml/AddedLabelElement.uxml
  6. 157
      com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor_OLD.cs
  7. 3
      com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor_OLD.cs.meta
  8. 10
      com.unity.perception/Editor/GroundTruth/Uxml/LabelConfig_Main.uxml
  9. 10
      com.unity.perception/Editor/GroundTruth/Uxml/LabelConfig_Main.uxml.meta
  10. 14
      com.unity.perception/Editor/GroundTruth/Uxml/LabelElementInLabelConfig.uxml
  11. 3
      com.unity.perception/Editor/GroundTruth/Uxml/LabelElementInLabelConfig.uxml.meta
  12. 3
      com.unity.perception/Editor/Icons/ChevronDown.png
  13. 142
      com.unity.perception/Editor/Icons/ChevronDown.png.meta
  14. 6
      com.unity.perception/Editor/Icons/ChevronDownPadded.png
  15. 142
      com.unity.perception/Editor/Icons/ChevronDownPadded.png.meta
  16. 4
      com.unity.perception/Editor/Icons/ChevronUp.png
  17. 142
      com.unity.perception/Editor/Icons/ChevronUp.png.meta
  18. 4
      com.unity.perception/Editor/Icons/ChevronUpPadded.png
  19. 142
      com.unity.perception/Editor/Icons/ChevronUpPadded.png.meta

278
com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.UIElements;
using UnityEditor.VersionControl;
using UnityEngine.UIElements;
namespace UnityEditor.Perception.GroundTruth
{

ReorderableList m_LabelsList;
const float k_Margin = 5f;
private ListView m_LabelListView;
private string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/";
private string m_UxmlPath;
private VisualElement m_Root;
private IdLabelConfig m_IdLabelConig;
private Button m_SaveButton;
private Button m_AddNewLabelButton
private List<string> m_AddedLabels = new List<string>();
private SerializedProperty m_SerializedLabelsArray;
m_LabelsList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty(IdLabelConfig.labelEntriesFieldName), true, false, true, true);
m_LabelsList.elementHeight = EditorGUIUtility.singleLineHeight * 2 + k_Margin;
m_LabelsList.drawElementCallback = DrawElement;
m_LabelsList.onAddCallback += OnAdd;
m_LabelsList.onRemoveCallback += OnRemove;
m_LabelsList.onReorderCallbackWithDetails += OnReorder;
m_UxmlPath = m_UxmlDir + "LabelConfig_Main.uxml";
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(m_UxmlPath).CloneTree();
m_LabelListView = m_Root.Q<ListView>("labels-listview");
m_SaveButton = m_Root.Q<Button>("save-button");
m_SaveButton.SetEnabled(false);
m_IdLabelConig = (IdLabelConfig)target;
m_SerializedLabelsArray = serializedObject.FindProperty(IdLabelConfig.labelEntriesFieldName);
if (autoAssign)
if (m_AutoAssign)
{
AutoAssignIds();
serializedObject.ApplyModifiedProperties();

RefreshAddedLabels();
SetupLabelsListView();
void OnReorder(ReorderableList list, int oldIndex, int newIndex)
public override VisualElement CreateInspectorGUI()
{
serializedObject.Update();
m_IdLabelConig = (IdLabelConfig)target;
RefreshAddedLabels();
m_LabelListView.Refresh();
return m_Root;
}
void RefreshAddedLabels()
{
m_AddedLabels.Clear();
m_AddedLabels.AddRange( m_IdLabelConig.labelEntries.Select(entry => entry.label));
}
void SetupLabelsListView()
{
m_LabelListView.itemsSource = m_AddedLabels;
VisualElement MakeItem() =>
new LabelElementInLabelConfig(this, m_SerializedLabelsArray, m_LabelListView);
void BindItem(VisualElement e, int i)
{
if (e is LabelElementInLabelConfig addedLabel)
{
addedLabel.m_IndexInList = i;
addedLabel.m_LabelTextField.BindProperty(m_SerializedLabelsArray.GetArrayElementAtIndex(i).FindPropertyRelative(nameof(IdLabelEntry.label)));
addedLabel.m_LabelId.text = m_IdLabelConig.labelEntries[i].id.ToString();
addedLabel.UpdateMoveButtonVisibility(m_SerializedLabelsArray);
}
}
const int itemHeight = 30;
m_LabelListView.bindItem = BindItem;
m_LabelListView.makeItem = MakeItem;
m_LabelListView.itemHeight = itemHeight;
m_LabelListView.selectionType = SelectionType.Single;
m_LabelListView.RegisterCallback<AttachToPanelEvent>(evt =>
{
RefreshListViewHeight();
});
}
public void SetSaveButtonEnabled(bool enabled)
if (!autoAssign)
return;
m_SaveButton.SetEnabled(enabled);
}
AutoAssignIds();
public void RefreshListViewHeight()
{
m_LabelListView.style.minHeight = Mathf.Clamp(m_LabelListView.itemsSource.Count * m_LabelListView.itemHeight, 300, 600);
void OnRemove(ReorderableList list)
bool m_AutoAssign => serializedObject.FindProperty(nameof(IdLabelConfig.autoAssignIds)).boolValue;
void AutoAssignIds()
if (list.index != -1)
list.serializedProperty.DeleteArrayElementAtIndex(list.index);
var serializedProperty = serializedObject.FindProperty(IdLabelConfig.labelEntriesFieldName);
var size = serializedProperty.arraySize;
if (size == 0)
return;
if (autoAssign)
AutoAssignIds();
var startingLabelId = (StartingLabelId)serializedObject.FindProperty(nameof(IdLabelConfig.startingLabelId)).enumValueIndex;
this.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
var nextId = startingLabelId == StartingLabelId.One ? 1 : 0;
for (int i = 0; i < size; i++)
{
serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative(nameof(IdLabelEntry.id)).intValue = nextId;
nextId++;
}
void OnAdd(ReorderableList list)
void AddNewLabel(SerializedProperty serializedArray, HashSet<string> presentLabels)
if (list.serializedProperty.arraySize == 0)
if (serializedArray.arraySize == 0)
for (int i = 0; i < list.serializedProperty.arraySize; i++)
for (int i = 0; i < serializedArray.arraySize; i++)
var item = list.serializedProperty.GetArrayElementAtIndex(i);
var item = serializedArray.GetArrayElementAtIndex(i);
var index = list.serializedProperty.arraySize;
list.serializedProperty.InsertArrayElementAtIndex(index);
var element = list.serializedProperty.GetArrayElementAtIndex(index);
var index = serializedArray.arraySize;
serializedArray.InsertArrayElementAtIndex(index);
var element = serializedArray.GetArrayElementAtIndex(index);
labelProperty.stringValue = "";
labelProperty.stringValue = FindNewLabelValue(presentLabels);
if (autoAssign)
AutoAssignIds();
// if (m_AutoAssign)
// AutoAssignIds();
EditorUtility.SetDirty(target);
//EditorUtility.SetDirty(target);
void DrawElement(Rect rect, int index, bool isactive, bool isfocused)
string FindNewLabelValue(HashSet<string> labels)
var element = m_LabelsList.serializedProperty.GetArrayElementAtIndex(index);
var idProperty = element.FindPropertyRelative(nameof(IdLabelEntry.id));
var labelProperty = element.FindPropertyRelative(nameof(IdLabelEntry.label));
using (var change = new EditorGUI.ChangeCheckScope())
string baseLabel = "New Label";
string label = baseLabel;
int count = 1;
while (labels.Contains(label))
var contentRect = new Rect(rect.position, new Vector2(rect.width, EditorGUIUtility.singleLineHeight));
using (new EditorGUI.DisabledScope(autoAssign))
{
var newLabel = EditorGUI.IntField(contentRect, nameof(IdLabelEntry.id), idProperty.intValue);
if (change.changed)
{
idProperty.intValue = newLabel;
if (autoAssign)
AutoAssignIds();
}
}
label = baseLabel + "_" + count++;
using (var change = new EditorGUI.ChangeCheckScope())
{
var contentRect = new Rect(rect.position + new Vector2(0, EditorGUIUtility.singleLineHeight), new Vector2(rect.width, EditorGUIUtility.singleLineHeight));
var newLabel = EditorGUI.TextField(contentRect, nameof(IdLabelEntry.label), labelProperty.stringValue);
if (change.changed)
{
labelProperty.stringValue = newLabel;
}
}
return label;
}
bool autoAssign => serializedObject.FindProperty(nameof(IdLabelConfig.autoAssignIds)).boolValue;
class LabelElementInLabelConfig : VisualElement
{
private string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/";
private string m_UxmlPath;
private Button m_RemoveButton;
private Button m_MoveUpButton;
private Button m_MoveDownButton;
public TextField m_LabelTextField;
public Label m_LabelId;
public int m_IndexInList;
public override void OnInspectorGUI()
public LabelElementInLabelConfig(IdLabelConfigEditor editor, SerializedProperty labelsArray, ListView labelsListView)
serializedObject.Update();
var autoAssignIdsProperty = serializedObject.FindProperty(nameof(IdLabelConfig.autoAssignIds));
using (var change = new EditorGUI.ChangeCheckScope())
m_UxmlPath = m_UxmlDir + "LabelElementInLabelConfig.uxml";
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(m_UxmlPath).CloneTree(this);
m_LabelTextField = this.Q<TextField>("label-value");
m_RemoveButton = this.Q<Button>("remove-button");
m_MoveUpButton = this.Q<Button>("move-up-button");
m_MoveDownButton = this.Q<Button>("move-down-button");
m_LabelId = this.Q<Label>("label-id-value");
m_MoveDownButton.clicked += () =>
EditorGUILayout.PropertyField(autoAssignIdsProperty, new GUIContent("Auto Assign IDs"));
if (change.changed && autoAssignIdsProperty.boolValue)
AutoAssignIds();
}
if (m_IndexInList < labelsArray.arraySize - 1)
{
var currentProperty =
labelsArray.GetArrayElementAtIndex(m_IndexInList).FindPropertyRelative(nameof(IdLabelEntry.label));
var bottomProperty = labelsArray.GetArrayElementAtIndex(m_IndexInList + 1)
.FindPropertyRelative("label");
var tmpString = bottomProperty.stringValue;
bottomProperty.stringValue = currentProperty.stringValue;
currentProperty.stringValue = tmpString;
m_IndexInList++;
labelsListView.SetSelection(m_IndexInList);
UpdateMoveButtonVisibility(labelsArray);
editor.serializedObject.ApplyModifiedProperties();
if (autoAssignIdsProperty.boolValue)
labelsListView.Refresh();
editor.RefreshListViewHeight();
//AssetDatabase.SaveAssets();
}
};
m_MoveUpButton.clicked += () =>
using (var change = new EditorGUI.ChangeCheckScope())
if (m_IndexInList > 0)
var startingLabelIdProperty = serializedObject.FindProperty(nameof(IdLabelConfig.startingLabelId));
EditorGUILayout.PropertyField(startingLabelIdProperty, new GUIContent("Starting Label ID"));
if (change.changed)
AutoAssignIds();
var currentProperty =
labelsArray.GetArrayElementAtIndex(m_IndexInList).FindPropertyRelative(nameof(IdLabelEntry.label));
var topProperty = labelsArray.GetArrayElementAtIndex(m_IndexInList - 1)
.FindPropertyRelative("label");
var tmpString = topProperty.stringValue;
topProperty.stringValue = currentProperty.stringValue;
currentProperty.stringValue = tmpString;
m_IndexInList--;
labelsListView.SetSelection(m_IndexInList);
UpdateMoveButtonVisibility(labelsArray);
editor.serializedObject.ApplyModifiedProperties();
labelsListView.Refresh();
editor.RefreshListViewHeight();
//AssetDatabase.SaveAssets();
}
};
m_LabelsList.DoLayoutList();
this.serializedObject.ApplyModifiedProperties();
}
m_LabelTextField.RegisterValueChangedCallback<string>((cEvent) =>
{
editor.SetSaveButtonEnabled(EditorUtility.IsDirty(editor.target));
});
void AutoAssignIds()
{
var serializedProperty = serializedObject.FindProperty(IdLabelConfig.labelEntriesFieldName);
var size = serializedProperty.arraySize;
if (size == 0)
return;
m_RemoveButton.clicked += () =>
{
var startingLabelId = (StartingLabelId)serializedObject.FindProperty(nameof(IdLabelConfig.startingLabelId)).enumValueIndex;
};
}
var nextId = startingLabelId == StartingLabelId.One ? 1 : 0;
for (int i = 0; i < size; i++)
{
serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative(nameof(IdLabelEntry.id)).intValue = nextId;
nextId++;
}
public void UpdateMoveButtonVisibility(SerializedProperty labelsArray)
{
m_MoveDownButton.visible = m_IndexInList != labelsArray.arraySize - 1;
m_MoveUpButton.visible = m_IndexInList != 0;
}
}
}

2
com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor.cs.meta


fileFormatVersion: 2
guid: 910dd3186e1c4fad8eb6aca9b9ee0f48
guid: 43cb2a3117353435abe59ca5217974a8
timeCreated: 1585940009

52
com.unity.perception/Editor/GroundTruth/LabelingEditor.cs


private List<string> m_SuggestedLabelsBasedOnName = new List<string>();
private List<string> m_SuggestedLabelsBasedOnPath = new List<string>();
private Dictionary<int, int> m_CommonsIndexToLabelsIndex = new Dictionary<int, int>();
private List<string> m_CommonLabels = new List<string>(); //labels that are common between all selected Labeling objects (for multi editing)
public List<string> CommonLabels => m_CommonLabels;

}
RemoveAddedLabelsFromSuggestedLists();
//Debug.Log("list update, source list count is:" + m_SuggestedLabelsBasedOnPath.Count);
}

{
m_CommonLabels = m_CommonLabels.Intersect(((Labeling) obj).labels).ToList();
}
Debug.Log("-----------------------------");
Debug.Log("common labels count: " + m_CommonLabels.Count);
m_CommonsIndexToLabelsIndex.Clear();
for (int i = 0; i < m_Labeling.labels.Count; i++)
{
string label = m_Labeling.labels[i];
for (int j = 0; j < m_CommonLabels.Count; j++)
{
string label2 = m_CommonLabels[j];
if (String.Equals(label, label2) && !m_CommonsIndexToLabelsIndex.ContainsKey(j))
{
m_CommonsIndexToLabelsIndex.Add(j, i);
}
}
}
Debug.Log("dict labels count: " + m_CommonsIndexToLabelsIndex.Count);
// if (m_CommonLabels.Count > 0 && serializedObject.targetObjects.Length > 1)
// {
// foreach (var VARIABLE in m_CommonLabels)
// {
// Debug.Log(VARIABLE);
// }
// }
}
//to know which index in the asset
Dictionary<int, int> CreateCommonLabelsToAssetsLabelsIndex()
{
return null;
}
void SetupCurrentLabelsListView()

if (e is AddedLabelEditor addedLabel)
{
addedLabel.m_IndexInList = i;
addedLabel.m_LabelTextField.value = m_SerializedLabelsArray.GetArrayElementAtIndex(m_CommonsIndexToLabelsIndex[i]).stringValue;
addedLabel.m_LabelTextField.value = m_CommonLabels[i];
}
}

m_CurrentLabelsListView.itemsSource = m_CommonLabels;
m_CurrentLabelsListView.selectionType = SelectionType.None;
//m_CurrentLabelsListView.reorderable = true;
//m_CurrentLabelsListView.selectionType = SelectionType.Multiple;
// #if UNITY_2020_1_OR_NEWER
// m_CurrentLabelsListView.selectionType = SelectionType.Single;
// m_CurrentLabelsListView.reorderable = true;
// m_CurrentLabelsListView.RegisterCallback<DragPerformEvent>(evt =>
// {
//
// });
// #endif
}
void SetupSuggestedLabelsListViews()

m_LabelTextField.isDelayed = true;
//The listview of added labels in the editor is only bound to the top target object, se we need to apply label modifications to other selected objects too
m_LabelTextField.RegisterValueChangedCallback<string>((cEvent) =>
{
foreach (var targetObject in editor.targets)

41
com.unity.perception/Editor/GroundTruth/Uss/Styles.uss


}
.labeling__added-label-value {
width: auto;
width: 40%;
flex-grow: 1;
color: black;
}

background-color: #313131;
border-width: 0px;
border-width: 0;
}

.labeling__label-listview {
flex-grow: 1;
min-height: 150px;
min-height: 150;
border-radius: 4px;
margin-right: 2px;
margin-top: 2px;

.labeling__add-label-button {
align-self: flex-end;
border-width: 0;
background-color: rgb(25, 25, 25);
background-color: #222222;
border-color: #707070;
border-width: 0;
margin-right: 2px;
margin-top: 2px;
color: #CACACA;

padding-top: 5px;
flex-grow: 1;
}
.outer-container-in-window{

.inner-container {
margin-top: 10px;
border-radius: 10px;
border-radius: 4px;
border-width: 1px;
padding: 10px;
background-color: rgb(75, 75, 75);

.labeling__add-to-list-button {
align-self: flex-end;
background-color: #505050;
border-width: 0px;
border-width: 0;
color: #EEEEEE;
}

-unity-text-align: middle-left;
background-color: #505050;
border-width: 0px;
border-width: 0;
color: #EEEEEE;
}

margin: 3px;
background-color: #272727;
}
.move-label-in-config-button{
background-color: #505050;
align-self: center;
}
.move-up{
background-image: resource('Packages/com.unity.perception/Editor/Icons/ChevronUpPadded.png');
}
.move-down{
background-image: resource('Packages/com.unity.perception/Editor/Icons/ChevronDownPadded.png');
}
.move-label-in-config-button:hover{
background-color: #808080;
}
.move-label-in-config-button:active{
background-color: #303030;
}

14
com.unity.perception/Editor/GroundTruth/Uxml/AddedLabelElement.uxml


<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xmlns="UnityEngine.UIElements" editor-extension-mode="False">
<ui:VisualElement class="added-label">
<ui:Button name="remove-button" class="labeling__remove-item-button" />
<ui:TextField name="label-value" class="labeling__added-label-value" />
<ui:Button name="add-to-config-button" text="Add to Label Config..." class="labeling__add-to-config-button" />
</ui:VisualElement>
</ui:UXML>
<UXML xmlns="UnityEngine.UIElements">
<VisualElement class="added-label">
<Button name="remove-button" class="labeling__remove-item-button" />
<TextField name="label-value" class="labeling__added-label-value" />
<Button name="add-to-config-button" text="Add to Label Config..." class="labeling__add-to-config-button" />
</VisualElement>
</UXML>

157
com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor_OLD.cs


//#define ENABLED
#if ENABLED
using System;
using Unity.Mathematics;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
namespace UnityEditor.Perception.GroundTruth
{
[CustomEditor(typeof(IdLabelConfig))]
class IdLabelConfigEditor : Editor
{
ReorderableList m_LabelsList;
const float k_Margin = 5f;
public void OnEnable()
{
m_LabelsList = new ReorderableList(this.serializedObject,
this.serializedObject.FindProperty(IdLabelConfig.labelEntriesFieldName), true, false, true, true);
m_LabelsList.elementHeight = EditorGUIUtility.singleLineHeight * 2 + k_Margin;
m_LabelsList.drawElementCallback = DrawElement;
m_LabelsList.onAddCallback += OnAdd;
m_LabelsList.onRemoveCallback += OnRemove;
m_LabelsList.onReorderCallbackWithDetails += OnReorder;
if (autoAssign)
{
AutoAssignIds();
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
}
void OnReorder(ReorderableList list, int oldIndex, int newIndex)
{
if (!autoAssign)
return;
AutoAssignIds();
}
void OnRemove(ReorderableList list)
{
if (list.index != -1)
list.serializedProperty.DeleteArrayElementAtIndex(list.index);
if (autoAssign)
AutoAssignIds();
this.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
void OnAdd(ReorderableList list)
{
int maxLabel = Int32.MinValue;
if (list.serializedProperty.arraySize == 0)
maxLabel = -1;
for (int i = 0; i < list.serializedProperty.arraySize; i++)
{
var item = list.serializedProperty.GetArrayElementAtIndex(i);
maxLabel = math.max(maxLabel, item.FindPropertyRelative(nameof(IdLabelEntry.id)).intValue);
}
var index = list.serializedProperty.arraySize;
list.serializedProperty.InsertArrayElementAtIndex(index);
var element = list.serializedProperty.GetArrayElementAtIndex(index);
var idProperty = element.FindPropertyRelative(nameof(IdLabelEntry.id));
idProperty.intValue = maxLabel + 1;
var labelProperty = element.FindPropertyRelative(nameof(IdLabelEntry.label));
labelProperty.stringValue = "";
if (autoAssign)
AutoAssignIds();
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
void DrawElement(Rect rect, int index, bool isactive, bool isfocused)
{
var element = m_LabelsList.serializedProperty.GetArrayElementAtIndex(index);
var idProperty = element.FindPropertyRelative(nameof(IdLabelEntry.id));
var labelProperty = element.FindPropertyRelative(nameof(IdLabelEntry.label));
using (var change = new EditorGUI.ChangeCheckScope())
{
var contentRect = new Rect(rect.position, new Vector2(rect.width, EditorGUIUtility.singleLineHeight));
using (new EditorGUI.DisabledScope(autoAssign))
{
var newLabel = EditorGUI.IntField(contentRect, nameof(IdLabelEntry.id), idProperty.intValue);
if (change.changed)
{
idProperty.intValue = newLabel;
if (autoAssign)
AutoAssignIds();
}
}
}
using (var change = new EditorGUI.ChangeCheckScope())
{
var contentRect = new Rect(rect.position + new Vector2(0, EditorGUIUtility.singleLineHeight), new Vector2(rect.width, EditorGUIUtility.singleLineHeight));
var newLabel = EditorGUI.TextField(contentRect, nameof(IdLabelEntry.label), labelProperty.stringValue);
if (change.changed)
{
labelProperty.stringValue = newLabel;
}
}
}
bool autoAssign => serializedObject.FindProperty(nameof(IdLabelConfig.autoAssignIds)).boolValue;
public override void OnInspectorGUI()
{
serializedObject.Update();
var autoAssignIdsProperty = serializedObject.FindProperty(nameof(IdLabelConfig.autoAssignIds));
using (var change = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.PropertyField(autoAssignIdsProperty, new GUIContent("Auto Assign IDs"));
if (change.changed && autoAssignIdsProperty.boolValue)
AutoAssignIds();
}
if (autoAssignIdsProperty.boolValue)
{
using (var change = new EditorGUI.ChangeCheckScope())
{
var startingLabelIdProperty = serializedObject.FindProperty(nameof(IdLabelConfig.startingLabelId));
EditorGUILayout.PropertyField(startingLabelIdProperty, new GUIContent("Starting Label ID"));
if (change.changed)
AutoAssignIds();
}
}
m_LabelsList.DoLayoutList();
this.serializedObject.ApplyModifiedProperties();
}
void AutoAssignIds()
{
var serializedProperty = serializedObject.FindProperty(IdLabelConfig.labelEntriesFieldName);
var size = serializedProperty.arraySize;
if (size == 0)
return;
var startingLabelId = (StartingLabelId)serializedObject.FindProperty(nameof(IdLabelConfig.startingLabelId)).enumValueIndex;
var nextId = startingLabelId == StartingLabelId.One ? 1 : 0;
for (int i = 0; i < size; i++)
{
serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative(nameof(IdLabelEntry.id)).intValue = nextId;
nextId++;
}
}
}
}
#endif

3
com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor_OLD.cs.meta


fileFormatVersion: 2
guid: 910dd3186e1c4fad8eb6aca9b9ee0f48
timeCreated: 1585940009

10
com.unity.perception/Editor/GroundTruth/Uxml/LabelConfig_Main.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement class="outer-container" name="outer-container">
<Style src="../Uss/Styles.uss"/>
<Label text="Added Labels" name="added-labels-title" class="title-label"/>
<ListView name="labels-listview" class="labeling__label-listview" style="margin-top: 5px;"/>
<Button name="save-button" text="Save" style="display:none"/>
<Button name="add-label" text="Add New Label" class="labeling__add-label-button"/>
</VisualElement>
</UXML>

10
com.unity.perception/Editor/GroundTruth/Uxml/LabelConfig_Main.uxml.meta


fileFormatVersion: 2
guid: 5a298ce54f2b64db49ada97cd180b99d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

14
com.unity.perception/Editor/GroundTruth/Uxml/LabelElementInLabelConfig.uxml


<UXML xmlns="UnityEngine.UIElements">
<VisualElement class="added-label">
<Button name="remove-button" class="labeling__remove-item-button" />
<VisualElement style = "flex-direction: row; padding: 3px; margin-left: 3px; margin-right: 3px; border-width: 1px; border-color: dimgray; border-radius: 4px;">
<Label name="label-id-title" text = "id = " style="align-self:center; color: #CACACA;"/>
<Label name="label-id-value" style="-unity-font-style: bold; color: #CACACA; min-width : 25px; align-self:center;"/>
</VisualElement>
<TextField name="label-value" class="labeling__added-label-value"/>
<VisualElement style="min-width:20px; flex-direction: row;">
<Button name="move-up-button" class="move-label-in-config-button move-up" style="margin-right:-2px"/>
<Button name="move-down-button" class="move-label-in-config-button move-down"/>
</VisualElement>
</VisualElement>
</UXML>

3
com.unity.perception/Editor/GroundTruth/Uxml/LabelElementInLabelConfig.uxml.meta


fileFormatVersion: 2
guid: 2961168094add41168cf3b38ba7009dd
timeCreated: 1603311500

3
com.unity.perception/Editor/Icons/ChevronDown.png

之前 之后
宽度: 32  |  高度: 32  |  大小: 2.1 KiB

142
com.unity.perception/Editor/Icons/ChevronDown.png.meta


fileFormatVersion: 2
guid: fa47b84af1c764637bf825673d76949a
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

6
com.unity.perception/Editor/Icons/ChevronDownPadded.png

之前 之后
宽度: 32  |  高度: 32  |  大小: 2.1 KiB

142
com.unity.perception/Editor/Icons/ChevronDownPadded.png.meta


fileFormatVersion: 2
guid: 7d8b0ddb7696e48a6a9e037ba7d08e73
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

4
com.unity.perception/Editor/Icons/ChevronUp.png

之前 之后
宽度: 32  |  高度: 32  |  大小: 2.1 KiB

142
com.unity.perception/Editor/Icons/ChevronUp.png.meta


fileFormatVersion: 2
guid: 7c5db57ceb3164158b79c2eceb75cdbc
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

4
com.unity.perception/Editor/Icons/ChevronUpPadded.png

之前 之后
宽度: 32  |  高度: 32  |  大小: 2.1 KiB

142
com.unity.perception/Editor/Icons/ChevronUpPadded.png.meta


fileFormatVersion: 2
guid: 110dd95b59b974fd28227e7a929eec75
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存