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 { private VisualElement m_Root; private VisualElement m_ManualLabelingContainer; private VisualElement m_AutoLabelingContainer; private VisualElement m_FromLabelConfigsContainer; private VisualElement m_SuggestedLabelsContainer; private VisualElement m_SuggestedOnNamePanel; private VisualElement m_SuggestedOnPathPanel; private ListView m_CurrentLabelsListView; private ListView m_SuggestLabelsListView_FromName; private ListView m_SuggestLabelsListView_FromPath; private ScrollView m_LabelConfigsScrollView; private PopupField m_LabelingSchemesPopup; private Button m_AddButton; private Button m_AddAutoLabelToConfButton; private Toggle m_AutoLabelingToggle; private Label m_CurrentAutoLabel; private Label m_CurrentAutoLabelTitle; private Label m_AddManualLabelsTitle; private Labeling m_Labeling; private string m_UxmlDir = "Packages/com.unity.perception/Editor/GroundTruth/Uxml/"; private string m_UxmlPath; private List m_SuggestedLabelsBasedOnName = new List(); private List m_SuggestedLabelsBasedOnPath = new List(); public List CommonLabels { get; private set; } = new List(); private List m_LabelConfigTypes; private readonly List m_AllLabelConfigsInProject = new List(); private 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 = {"/"}; private 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_SuggestLabelsListView_FromName = m_Root.Q("suggested-labels-name-listview"); m_SuggestLabelsListView_FromPath = 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