Ejemplo n.º 1
0
    private Rect DrawLabel(bool showContextMenu, BaseExposedPropertyDrawer.OverrideState currentOverrideState, GUIContent label, Rect position, IExposedPropertyTable exposedPropertyTable, string exposedNameStr, SerializedProperty exposedName, SerializedProperty defaultValue)
    {
        if (showContextMenu)
        {
            position.xMax -= BaseExposedPropertyDrawer.kDriveWidgetWidth;
        }
        EditorGUIUtility.SetBoldDefaultFont(currentOverrideState != BaseExposedPropertyDrawer.OverrideState.DefaultValue);
        this.m_ModifiedLabel.text    = label.text;
        this.m_ModifiedLabel.tooltip = label.tooltip;
        this.m_ModifiedLabel.image   = label.image;
        if (!string.IsNullOrEmpty(this.m_ModifiedLabel.tooltip))
        {
            GUIContent expr_78 = this.m_ModifiedLabel;
            expr_78.tooltip += "\n";
        }
        if (currentOverrideState == BaseExposedPropertyDrawer.OverrideState.MissingOverride)
        {
            GUI.color = BaseExposedPropertyDrawer.kMissingOverrideColor;
            GUIContent expr_A6 = this.m_ModifiedLabel;
            string     tooltip = expr_A6.tooltip;
            expr_A6.tooltip = string.Concat(new string[]
            {
                tooltip,
                label.text,
                " ",
                this.NotFoundOn.text,
                " ",
                exposedPropertyTable.ToString(),
                "."
            });
        }
        else if (currentOverrideState == BaseExposedPropertyDrawer.OverrideState.Overridden && exposedPropertyTable != null)
        {
            GUIContent expr_115 = this.m_ModifiedLabel;
            expr_115.tooltip = expr_115.tooltip + this.OverridenByContent.text + exposedPropertyTable.ToString() + ".";
        }
        Rect result = EditorGUI.PrefixLabel(position, this.m_ModifiedLabel);

        if (exposedPropertyTable != null && Event.current.type == EventType.ContextClick)
        {
            if (position.Contains(Event.current.mousePosition))
            {
                GenericMenu genericMenu = new GenericMenu();
                this.PopulateContextMenu(genericMenu, (!string.IsNullOrEmpty(exposedNameStr)) ? BaseExposedPropertyDrawer.OverrideState.Overridden : BaseExposedPropertyDrawer.OverrideState.DefaultValue, exposedPropertyTable, exposedName, defaultValue);
                genericMenu.ShowAsContext();
            }
        }
        return(result);
    }
Ejemplo n.º 2
0
    Rect DrawLabel(bool showContextMenu, OverrideState currentOverrideState, GUIContent label, Rect position, IExposedPropertyTable exposedPropertyTable, string exposedNameStr, SerializedProperty exposedName, SerializedProperty defaultValue)
    {
        if (showContextMenu)
        {
            position.xMax = position.xMax - ExposedReferencePropertyDrawer.kDriveWidgetWidth;
        }

        EditorGUIUtility.SetBoldDefaultFont(currentOverrideState != OverrideState.DefaultValue);

        m_ModifiedLabel.text    = label.text;
        m_ModifiedLabel.tooltip = label.tooltip;
        m_ModifiedLabel.image   = label.image;

        if (!string.IsNullOrEmpty(m_ModifiedLabel.tooltip))
        {
            m_ModifiedLabel.tooltip += "\n";
        }
        if (currentOverrideState == OverrideState.MissingOverride)
        {
            GUI.color = kMissingOverrideColor;
            m_ModifiedLabel.tooltip += label.text + " " + NotFoundOn.text + " " + exposedPropertyTable.ToString() + ".";
        }
        else if (currentOverrideState == OverrideState.Overridden && exposedPropertyTable != null)
        {
            m_ModifiedLabel.tooltip += OverridenByContent.text + exposedPropertyTable.ToString() + ".";
        }

        var prefixRect = EditorGUI.PrefixLabel(position, m_ModifiedLabel);

        // Show contextual menu
        if (exposedPropertyTable != null && Event.current.type == EventType.ContextClick)
        {
            if (position.Contains(Event.current.mousePosition))
            {
                GenericMenu menu = new GenericMenu();
                PopulateContextMenu(menu, string.IsNullOrEmpty(exposedNameStr) ? OverrideState.DefaultValue : OverrideState.Overridden, exposedPropertyTable, exposedName, defaultValue);
                menu.ShowAsContext();
            }
        }

        return(prefixRect);
    }