using System; using UnityEngine; using UnityObject = UnityEngine.Object; namespace Unity.Tutorials.Core.Editor { /// /// Used the select which GUI controls are unmasked. /// [Serializable] public class GuiControlSelector { /// /// Supported selector modes. /// public enum Mode { /// /// Select by GUIContent (IMGUI). /// GuiContent, /// /// Select by Named Control's name, the name used for GUI.SetNextControlName() (IMGUI). /// NamedControl, /// /// Select by property's path name (IMGUI). /// Property, /// /// Select by GUIStyle's name (IMGUI). /// GuiStyleName, /// /// Match by the referenced Unity Object (IMGUI). /// ObjectReference, /// /// Select by VisualElement's name and class name (UI Toolkit). /// VisualElement, } /// /// Supported selector match types. /// public enum MatchType { /// /// Select the last matching control. /// Last, /// /// Select the first matching control. /// First, /// /// Select all matching controls. /// All, } /// /// The mode by which the UI element is chosen. /// public Mode SelectorMode { get => m_SelectorMode; set => m_SelectorMode = value; } [SerializeField] Mode m_SelectorMode; /// /// The used match type in case of the selector matches multiple UI elements. /// public MatchType SelectorMatchType { get => m_SelectorMatchType; set => m_SelectorMatchType = value; } [SerializeField] internal MatchType m_SelectorMatchType; /// /// Applicable if Mode.GuiContent used. /// public GUIContent GuiContent { get => new GUIContent(m_GUIContent); set => m_GUIContent = new GUIContent(value); } [SerializeField] GUIContent m_GUIContent = new GUIContent(); /// /// Applicable if Mode.NamedControl used. /// public string ControlName { get => m_ControlName; set => m_ControlName = value ?? ""; } [SerializeField] string m_ControlName = ""; /// /// Applicable if Mode.Property used. /// public string PropertyPath { get => m_PropertyPath; set => m_PropertyPath = value ?? ""; } [SerializeField] string m_PropertyPath = ""; /// /// Applicable if Mode.Property used. /// public Type TargetType { get => m_TargetType.Type; set => m_TargetType.Type = value; } [SerializeField, SerializedTypeFilter(typeof(UnityObject), false)] SerializedType m_TargetType = new SerializedType(null); /// /// Applicable if Mode.GuiStyleName used. /// public string GuiStyleName { get => m_GUIStyleName; set => m_GUIStyleName = value; } [SerializeField] string m_GUIStyleName; /// /// A reference to a Unity Object of which name will be matched against the text in UI elements. /// Applicable if Mode.ObjectReference used. /// /// /// In order for this to work for assets, the asset must have a short name, i.e., /// the name cannot be visible in the UI in shortened form, e.g. "A longer...". /// public ObjectReference ObjectReference { get => m_ObjectReference; set => m_ObjectReference = value; } [SerializeField] ObjectReference m_ObjectReference; /// /// Unity style sheet class name. Applicable if Mode.VisualElement used. /// public string VisualElementClassName { get => m_VisualElementClassName; set => m_VisualElementClassName = value; } [Tooltip("Unity style sheet class name."), SerializeField] internal string m_VisualElementClassName; /// /// The name of the element. Applicable if Mode.VisualElement used. /// public string VisualElementName { get => m_VisualElementName; set => m_VisualElementName = value; } [Tooltip("The name of the element."), SerializeField] internal string m_VisualElementName; /// /// The fully qualified C# class/type name of the element. Applicable if Mode.VisualElement used. /// public string VisualElementTypeName { get => m_VisualElementTypeName; set => m_VisualElementTypeName = value; } [Tooltip("The fully qualified C# class/type name of the element."), SerializeField] internal string m_VisualElementTypeName; } }