예제 #1
0
        public override bool SetProperty(string name, object value)
        {
            if (base.SetProperty(name, value))
            {
                return(true);
            }

            switch (name)
            {
            case "img":
            case "value":
            case "texture":
            case "src":
                if (value as Texture != null)
                {
                    _texture = (Texture)value;
                }
                else
                {
                    Texture temp = AssetDatabase.LoadAssetAtPath <Texture>(value.ToString());
                    if (temp != null)
                    {
                        _texture = temp;
                    }
                    else
                    {
                        Debug.LogError("EditorX failed to load image: No texture located at " + value.ToString());
                    }
                }
                return(true);

            case "scale-mode":
                _scaleMode = (ScaleMode)EnumUtility.GetEnumObject(typeof(ScaleMode), value.ToString());
                return(true);

            default:
                return(false);
            }
        }
예제 #2
0
 public override void OnAfterDeserialize()
 {
     base.OnAfterDeserialize();
     _value = EnumUtility.GetEnumObject(enumType, _valueIndex);
 }
예제 #3
0
        public virtual void Update()
        {
            _layoutOptionsList.Clear();
            object temp = null;

            if (_data.TryGetValue("width", out temp))
            {
                float val = (temp.GetType() == typeof(float)) ? (float)temp : (float)(int)temp;
                _layoutOptionsList.Add(GUILayout.Width(val));
            }
            temp = null;
            if (_data.TryGetValue("height", out temp))
            {
                float val = (temp.GetType() == typeof(float)) ? (float)temp : (float)(int)temp;
                _layoutOptionsList.Add(GUILayout.Height(val));
            }
            temp = null;
            if (_data.TryGetValue("background-color", out temp) || _data.TryGetValue("backgroundcolor", out temp))
            {
                backgroundColor = (Color)temp;
            }
            temp = null;
            if (_data.TryGetValue("background", out temp))
            {
                _guiStyle.normal.background = (Texture2D)temp;
            }
            temp = null;
            if (_data.TryGetValue("font", out temp))
            {
                _guiStyle.font = (Font)temp;
            }
            temp = null;
            if (_data.TryGetValue("font-style", out temp) || _data.TryGetValue("fontstyle", out temp))
            {
                _guiStyle.fontStyle = (FontStyle)temp;
            }
            temp = null;
            if (_data.TryGetValue("font-size", out temp) || _data.TryGetValue("fontsize", out temp))
            {
                _guiStyle.fontSize = (int)(float)temp;
            }
            temp = null;
            if (_data.TryGetValue("alignment", out temp))
            {
                TextAnchor anchor = (temp.GetType() == typeof(string)) ? (TextAnchor)EnumUtility.GetEnumObject(typeof(TextAnchor), (string)temp) : (TextAnchor)temp;
                _guiStyle.alignment = anchor;
            }
            temp = null;
            if (_data.TryGetValue("position", out temp))
            {
                PositionType postype = (temp.GetType() == typeof(string)) ? (PositionType)EnumUtility.GetEnumObject(typeof(PositionType), (string)temp) : (PositionType)temp;
                _position = postype;
            }
            temp = null;
            if (_data.TryGetValue("image-position", out temp))
            {
                ImagePosition impos = (temp.GetType() == typeof(string)) ? (ImagePosition)EnumUtility.GetEnumObject(typeof(ImagePosition), (string)temp) : (ImagePosition)temp;
                _guiStyle.imagePosition = impos;
            }
            temp = null;
            if (_data.TryGetValue("margin", out temp))
            {
                _guiStyle.margin = RectUtility.ReadRectOffset(temp.ToString());
            }
            temp = null;
            if (_data.TryGetValue("padding", out temp))
            {
                _guiStyle.padding = RectUtility.ReadRectOffset(temp.ToString());
            }
            temp = null;
            if (_data.TryGetValue("color", out temp))
            {
                color = (Color)temp;
            }
            temp = null;
            if (_data.TryGetValue("expand-width", out temp))
            {
                _layoutOptionsList.Add(GUILayout.ExpandWidth((bool)temp));
            }
            temp = null;
            if (_data.TryGetValue("expand-height", out temp))
            {
                _layoutOptionsList.Add(GUILayout.ExpandHeight((bool)temp));
            }
            temp = null;
            if (_data.TryGetValue("min-width", out temp))
            {
                float val = (temp.GetType() == typeof(float)) ? (float)temp : (float)(int)temp;
                _layoutOptionsList.Add(GUILayout.MinWidth(val));
            }
            temp = null;
            if (_data.TryGetValue("max-width", out temp))
            {
                float val = (temp.GetType() == typeof(float)) ? (float)temp : (float)(int)temp;
                _layoutOptionsList.Add(GUILayout.MaxWidth(val));
            }
            temp = null;
            if (_data.TryGetValue("min-height", out temp))
            {
                float val = (temp.GetType() == typeof(float)) ? (float)temp : (float)(int)temp;
                _layoutOptionsList.Add(GUILayout.MinHeight(val));
            }
            temp = null;
            if (_data.TryGetValue("max-height", out temp))
            {
                float val = (temp.GetType() == typeof(float)) ? (float)temp : (float)(int)temp;
                _layoutOptionsList.Add(GUILayout.MaxHeight(val));
            }
            _layoutOptions = _layoutOptionsList.ToArray();
            _isDirty       = false;
        }