Exemplo n.º 1
0
        private void UpdateIcon(HelpBoxMessageType messageType)
        {
            bool flag = !string.IsNullOrEmpty(this.m_IconClass);

            if (flag)
            {
                this.m_Icon.RemoveFromClassList(this.m_IconClass);
            }
            this.m_IconClass = this.GetIconClass(messageType);
            bool flag2 = this.m_IconClass == null;

            if (flag2)
            {
                this.m_Icon.RemoveFromHierarchy();
            }
            else
            {
                this.m_Icon.AddToClassList(this.m_IconClass);
                bool flag3 = this.m_Icon.parent == null;
                if (flag3)
                {
                    base.Insert(0, this.m_Icon);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Show info help box with text if another class member value passes comparison.
        /// </summary>
        /// <param name="setText"> Text to show. </param>
        /// <param name="setClassMemberName"> Name of class member whose value to check. </param>
        /// <param name="comparison"> Type of comparison check to perform on value. </param>
        /// <param name="setRequiredValue"> The value the class member must have in order for the help box to be shown. </param>
        public HelpBoxAttribute(string setText, string setClassMemberName, Is comparison, object setRequiredValue)
        {
            text        = setText;
            messageType = HelpBoxMessageType.Info;

            alwaysShow          = false;
            classMemberName     = setClassMemberName;
            comparisonType      = comparison;
            requiredValue       = setRequiredValue;
            evaluatorExpression = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Show help box of given type with text.
        /// </summary>
        /// <param name="setText"> Text to show. </param>
        /// <param name="setMessageType"> Type of the message; info, warning or error. </param>
        public HelpBoxAttribute(string setText, HelpBoxMessageType setMessageType)
        {
            text        = setText;
            messageType = setMessageType;

            alwaysShow          = true;
            classMemberName     = "";
            requiredValue       = true;
            comparisonType      = Is.Equal;
            evaluatorExpression = null;
        }
Exemplo n.º 4
0
 public HelpBox(string text, HelpBoxMessageType messageType)
 {
     base.AddToClassList(HelpBox.ussClassName);
     this.m_HelpBoxMessageType = messageType;
     this.m_Label = new Label(text);
     this.m_Label.AddToClassList(HelpBox.labelUssClassName);
     base.Add(this.m_Label);
     this.m_Icon = new VisualElement();
     this.m_Icon.AddToClassList(HelpBox.iconUssClassName);
     this.UpdateIcon(messageType);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Show help box of given type with text if conditional expression is true.
        /// </summary>
        /// <param name="setText"> Text to show. </param>
        /// <param name="booleanExpression">
        /// The conditional expression which must be true for the help box to be shown.
        /// This can contain multiple comparisons between class members and target values.
        /// Example: intField == 3 && (floatField > 8 || EditorApplication.isPlaying)
        /// </param>
        /// <param name="setMessageType"> Type of the message; info, warning or error. </param>
        public HelpBoxAttribute(string setText, string booleanExpression, HelpBoxMessageType setMessageType)
        {
            text        = setText;
            messageType = setMessageType;

            alwaysShow          = false;
            classMemberName     = "";
            comparisonType      = Is.Equal;
            requiredValue       = "";
            evaluatorExpression = booleanExpression;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Show help box of given type with text if another class member has given value.
        /// </summary>
        /// <param name="setText"> Text to show. </param>
        /// <param name="setMessageType"> Type of the message; info, warning or error. </param>
        /// <param name="setClassMemberName"> Name of class member whose value to check. </param>
        /// <param name="setRequiredValue"> The value the class member must have in order for the help box to be shown. </param>
        public HelpBoxAttribute(string setText, HelpBoxMessageType setMessageType, string setClassMemberName, object setRequiredValue)
        {
            text        = setText;
            messageType = setMessageType;

            alwaysShow          = false;
            classMemberName     = setClassMemberName;
            comparisonType      = Is.Equal;
            requiredValue       = setRequiredValue;
            evaluatorExpression = null;
        }
Exemplo n.º 7
0
        string GetIconClass(HelpBoxMessageType messageType)
        {
            switch (messageType)
            {
            case HelpBoxMessageType.Info:    return(iconInfoUssClassName);

            case HelpBoxMessageType.Warning: return(iconwarningUssClassName);

            case HelpBoxMessageType.Error:   return(iconErrorUssClassName);
            }
            return(null);
        }
Exemplo n.º 8
0
        private MessageType GetMessageType(HelpBoxMessageType helpBoxMessageType)
        {
            switch (helpBoxMessageType)
            {
            default:
            case HelpBoxMessageType.Info: return(MessageType.Info);

            case HelpBoxMessageType.Warning: return(MessageType.Warning);

            case HelpBoxMessageType.Error: return(MessageType.Error);
            }
        }
Exemplo n.º 9
0
        public HelpBox(string text, HelpBoxMessageType messageType)
        {
            AddToClassList(ussClassName);

            m_HelpBoxMessageType = messageType;
            m_Label = new Label(text);
            m_Label.AddToClassList(labelUssClassName);
            Add(m_Label);

            m_Icon = new VisualElement();
            m_Icon.AddToClassList(iconUssClassName);
            UpdateIcon(messageType);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Show help box of given type with text if another class member value passes comparison.
        /// </summary>
        /// <param name="setText"> Text to show. </param>
        /// <param name="setMessageType"> Type of the message; info, warning or error. </param>
        /// <param name="comparison"> Type of comparison check to perform on value. </param>
        /// <param name="setRequiredValue"> The value the class member must have in order for the help box to be shown. </param>
        /// <param name="setRequiredValue"> Minimum height for the text box. </param>
        public HelpBoxAttribute(string setText, HelpBoxMessageType setMessageType, Is comparison, object setRequiredValue, float setMinHeight)
        {
            text        = setText;
            messageType = setMessageType;

            alwaysShow          = false;
            classMemberName     = "";
            comparisonType      = comparison;
            requiredValue       = setRequiredValue;
            evaluatorExpression = null;

            minHeight = setMinHeight;
        }
Exemplo n.º 11
0
        void UpdateIcon(HelpBoxMessageType messageType)
        {
            // Remove the old style
            if (!string.IsNullOrEmpty(m_IconClass))
            {
                m_Icon.RemoveFromClassList(m_IconClass);
            }

            m_IconClass = GetIconClass(messageType);

            if (m_IconClass == null)
            {
                m_Icon.RemoveFromHierarchy();
            }
            else
            {
                m_Icon.AddToClassList(m_IconClass);
                if (m_Icon.parent == null)
                {
                    Insert(0, m_Icon);
                }
            }
        }
Exemplo n.º 12
0
        private string GetIconClass(HelpBoxMessageType messageType)
        {
            string result;

            switch (messageType)
            {
            case HelpBoxMessageType.Info:
                result = HelpBox.iconInfoUssClassName;
                break;

            case HelpBoxMessageType.Warning:
                result = HelpBox.iconwarningUssClassName;
                break;

            case HelpBoxMessageType.Error:
                result = HelpBox.iconErrorUssClassName;
                break;

            default:
                result = null;
                break;
            }
            return(result);
        }
Exemplo n.º 13
0
 private void ShowHelpBox(HelpBoxMessageType messageType, string message)
 {
     m_HelpBox.SetVisibility(Visibility.Visible);
     MarkDirtyRepaint();
 }
Exemplo n.º 14
0
 public HelpBoxAttribute(string message, HelpBoxMessageType messageType = HelpBoxMessageType.Info)
 {
     this.message     = message;
     this.messageType = messageType;
 }
Exemplo n.º 15
0
 public HelpBoxAttribute(string text, HelpBoxMessageType messageType = HelpBoxMessageType.None)
 {
     this.text        = text;
     this.messageType = messageType;
 }
Exemplo n.º 16
0
        private void Setup(string text, [CanBeNull] LinkedMemberInfo attributeTarget, [CanBeNull] IParentDrawer setParent, HelpBoxMessageType setMessageType = HelpBoxMessageType.Info, IShowInInspectorIf showInInspectorEvaluator = null, float setMinHeight = 31f)
        {
            showHelpBoxEvaluator = showInInspectorEvaluator;
            minHeight            = setMinHeight + PreviousFieldOffset + NextFieldOffset;

            switch (setMessageType)
            {
            case HelpBoxMessageType.Info:
                messageType = MessageType.Info;
                break;

            case HelpBoxMessageType.Warning:
                messageType = MessageType.Warning;
                break;

            case HelpBoxMessageType.Error:
                messageType = MessageType.Error;
                break;

            default:
                throw new IndexOutOfRangeException();
            }

            base.Setup(text, typeof(string), attributeTarget, setParent, GUIContentPool.Create(text), false);

            float drawWidth = setParent != null ? setParent.Bounds.width : DrawGUI.InspectorWidth;

            UpdateHeight(drawWidth - IconWidth);
        }
Exemplo n.º 17
0
 private void DisplayAssetsCacheErrorBox(HelpBoxMessageType type, string message)
 {
     assetsCacheErrorBox.messageType = type;
     assetsCacheErrorBox.text        = message;
     UIUtils.SetElementDisplay(assetsCacheErrorBox, true);
 }
Exemplo n.º 18
0
 private void DisplayPackagesCacheErrorBox(HelpBoxMessageType type, string message)
 {
     packagesCacheErrorBox.messageType = type;
     packagesCacheErrorBox.text        = message;
     UIUtils.SetElementDisplay(packagesCacheErrorBox, true);
 }