Ejemplo n.º 1
0
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                HelpBox helpBox = ve as HelpBox;

                helpBox.text        = this.m_Text.GetValueFromBag(bag, cc);
                helpBox.messageType = this.m_MessageType.GetValueFromBag(bag, cc);
            }
        public BuilderInspectorHeader(BuilderInspector inspector)
        {
            m_Inspector       = inspector;
            m_Selection       = inspector.selection;
            m_Header          = m_Inspector.Q <VisualElement>("header-container");
            m_StatusIndicator = m_Header.Q <FieldStatusIndicator>("header-field-status-indicator");
            m_StatusIndicator.populateMenuItems = (menu) =>
            {
                BuildNameFieldContextualMenu(menu, m_TextField);
            };

            m_InnerHeader = m_Inspector.Q <VisualElement>("header-container-minor");
            m_Icon        = m_Inspector.Q <VisualElement>("header-icon");

            m_Pill = m_Inspector.Q <Label>("header-selected-pill");
            m_Pill.AddToClassList("unity-builder-tag-pill");

            m_TextField             = m_Inspector.Q <TextField>("header-selected-text-field");
            m_TextField.isDelayed   = true;
            m_TextField.tooltip     = "name";
            m_TextField.bindingPath = "name";

            m_EditorWarningHelpBox      = m_Inspector.Q <UnityEngine.UIElements.HelpBox>("header-editor-warning-help-box");
            m_EditorWarningHelpBox.text = BuilderConstants.HeaderSectionHelpBoxMessage;
            m_ErrorIcon = m_Inspector.Q <VisualElement>("header-error-icon");

            // Warning must be hidden at first
            m_ErrorIcon.style.backgroundImage = EditorGUIUtility.LoadIcon("console.erroricon");
            AdjustBottomPadding(false);

            // Store callbacks to reduce delegate allocations
            m_ElementNameChangeCallback    = new EventCallback <ChangeEvent <string> >(OnNameAttributeChange);
            m_SelectorNameChangeCallback   = new EventCallback <ChangeEvent <string> >(OnStyleSelectorNameChange);
            m_SelectorEnterKeyDownCallback = new EventCallback <KeyDownEvent>(OnEnterStyleSelectorNameChange);

            m_TextField.RegisterValueChangedCallback(m_ElementNameChangeCallback);
            m_RightClickManipulator = new ContextualMenuManipulator(BuildNameFieldContextualMenu);
        }