FairyGUI.Utils.HtmlElement.GetColor C# (CSharp) Method

GetColor() public method

public GetColor ( string attrName, Color defValue ) : Color
attrName string
defValue UnityEngine.Color
return UnityEngine.Color
        public Color GetColor(string attrName, Color defValue)
        {
            string value = GetString(attrName);
            if (value == null || value.Length == 0)
                return defValue;

            return ToolSet.ConvertFromHtmlColor(value);
        }

Usage Example

Example #1
0
        public void Create(RichTextField owner, HtmlElement element)
        {
            _owner   = owner;
            _element = element;

            string type = element.GetString("type");

            if (type != null)
            {
                type = type.ToLower();
            }

            _hidden = type == "hidden";
            if (!_hidden)
            {
                int   width           = element.GetInt("width", 0);
                int   height          = element.GetInt("height", 0);
                int   borderSize      = element.GetInt("border", defaultBorderSize);
                Color borderColor     = element.GetColor("border-color", defaultBorderColor);
                Color backgroundColor = element.GetColor("background-color", defaultBackgroundColor);

                if (width == 0)
                {
                    width = element.space;
                    if (width > _owner.width / 2 || width < 100)
                    {
                        width = (int)_owner.width / 2;
                    }
                }
                if (height == 0)
                {
                    height = element.format.size + 10;
                }

                textInput.textFormat        = element.format;
                textInput.displayAsPassword = type == "password";
                textInput.maxLength         = element.GetInt("maxlength", int.MaxValue);
                textInput.border            = borderSize;
                textInput.borderColor       = borderColor;
                textInput.backgroundColor   = backgroundColor;
                textInput.SetSize(width, height);
            }
            textInput.text = element.GetString("value");
        }
All Usage Examples Of FairyGUI.Utils.HtmlElement::GetColor