using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.Perception.GroundTruth; using UnityEngine.UIElements; using Button = UnityEngine.UIElements.Button; using Toggle = UnityEngine.UIElements.Toggle; namespace UnityEditor.Perception.GroundTruth { [CustomEditor(typeof(Labeling)), CanEditMultipleObjects] class LabelingEditor : Editor { VisualElement m_Root; VisualElement m_ManualLabelingContainer; VisualElement m_AutoLabelingContainer; VisualElement m_FromLabelConfigsContainer; VisualElement m_SuggestedLabelsContainer; VisualElement m_SuggestedOnNamePanel; VisualElement m_SuggestedOnPathPanel; ListView m_CurrentLabelsListView; ListView m_SuggestedLabelsListViewFromName; ListView m_SuggestedLabelsListViewFromPath; ScrollView m_LabelConfigsScrollView; PopupField m_LabelingSchemesPopup; Button m_AddButton; Button m_AddAutoLabelToConfButton; Toggle m_AutoLabelingToggle; Label m_CurrentAutoLabel; Label m_CurrentAutoLabelTitle; Label m_AddManualLabelsTitle; Labeling m_Labeling; string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/"; string m_UxmlPath; List m_SuggestedLabelsBasedOnName = new List(); List m_SuggestedLabelsBasedOnPath = new List(); public List CommonLabels { get; private set; } = new List(); List m_LabelConfigTypes; readonly List m_AllLabelConfigsInProject = new List(); readonly List m_LabelingSchemes = new List(); /// /// List of separator characters used for parsing asset names for auto labeling or label suggestion purposes /// public static readonly string[] NameSeparators = {".", "-", "_"}; /// /// List of separator characters used for parsing asset paths for auto labeling or label suggestion purposes /// public static readonly string[] PathSeparators = {"/"}; void OnEnable() { m_LabelConfigTypes = AddToConfigWindow.FindAllSubTypes(typeof(LabelConfig<>)); var mySerializedObject = new SerializedObject(serializedObject.targetObjects[0]); m_Labeling = mySerializedObject.targetObject as Labeling; m_UxmlPath = m_UxmlDir + "Labeling_Main.uxml"; m_Root = AssetDatabase.LoadAssetAtPath(m_UxmlPath).CloneTree(); m_CurrentLabelsListView = m_Root.Q("current-labels-listview"); m_SuggestedLabelsListViewFromName = m_Root.Q("suggested-labels-name-listview"); m_SuggestedLabelsListViewFromPath = m_Root.Q("suggested-labels-path-listview"); m_LabelConfigsScrollView = m_Root.Q("label-configs-scrollview"); m_SuggestedOnNamePanel = m_Root.Q("suggested-labels-from-name"); m_SuggestedOnPathPanel = m_Root.Q("suggested-labels-from-path"); m_AddButton = m_Root.Q