Пример #1
0
        public StyleBackground ReadStyleBackground(int index)
        {
            ImageSource        imageSource        = default(ImageSource);
            StylePropertyValue stylePropertyValue = this.m_Values[this.m_CurrentValueIndex + index];
            bool flag = stylePropertyValue.handle.valueType == StyleValueType.Keyword;

            if (flag)
            {
                bool flag2 = stylePropertyValue.handle.valueIndex != 6;
                if (flag2)
                {
                    string            arg_68_0   = "Invalid keyword for image source ";
                    StyleValueKeyword valueIndex = (StyleValueKeyword)stylePropertyValue.handle.valueIndex;
                    Debug.LogWarning(arg_68_0 + valueIndex.ToString());
                }
            }
            else
            {
                bool flag3 = !StylePropertyReader.TryGetImageSourceFromValue(stylePropertyValue, this.dpiScaling, out imageSource);
                if (flag3)
                {
                    imageSource.texture = (Panel.LoadResource("d_console.warnicon", typeof(Texture2D), this.dpiScaling) as Texture2D);
                }
            }
            bool            flag4 = imageSource.texture != null;
            StyleBackground result;

            if (flag4)
            {
                result = new StyleBackground(imageSource.texture);
            }
            else
            {
                bool flag5 = imageSource.vectorImage != null;
                if (flag5)
                {
                    result = new StyleBackground(imageSource.vectorImage);
                }
                else
                {
                    result = default(StyleBackground);
                }
            }
            return(result);
        }
        public bool TryGetValue(CustomStyleProperty <VectorImage> property, out VectorImage value)
        {
            CustomPropertyHandle propertyHandle;

            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out propertyHandle))
            {
                var source    = new ImageSource();
                var propValue = propertyHandle.value;
                if (StylePropertyReader.TryGetImageSourceFromValue(propValue, out source) && source.vectorImage != null)
                {
                    value = source.vectorImage;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
Пример #3
0
        public StyleCursor ReadStyleCursor(int index)
        {
            float          x = 0f;
            float          y = 0f;
            int            defaultCursorId = 0;
            Texture2D      texture         = null;
            StyleValueType valueType       = this.GetValueType(index);
            bool           flag            = valueType == StyleValueType.ResourcePath || valueType == StyleValueType.AssetReference || valueType == StyleValueType.ScalableImage;
            bool           flag2           = flag;

            if (flag2)
            {
                bool flag3 = this.valueCount < 1;
                if (flag3)
                {
                    Debug.LogWarning(string.Format("USS 'cursor' has invalid value at {0}.", index));
                }
                else
                {
                    ImageSource        imageSource = default(ImageSource);
                    StylePropertyValue value       = this.GetValue(index);
                    bool flag4 = StylePropertyReader.TryGetImageSourceFromValue(value, this.dpiScaling, out imageSource);
                    if (flag4)
                    {
                        texture = imageSource.texture;
                        bool flag5 = this.valueCount >= 3;
                        if (flag5)
                        {
                            StylePropertyValue value2 = this.GetValue(index + 1);
                            StylePropertyValue value3 = this.GetValue(index + 2);
                            bool flag6 = value2.handle.valueType != StyleValueType.Float || value3.handle.valueType != StyleValueType.Float;
                            if (flag6)
                            {
                                Debug.LogWarning("USS 'cursor' property requires two integers for the hot spot value.");
                            }
                            else
                            {
                                x = value2.sheet.ReadFloat(value2.handle);
                                y = value3.sheet.ReadFloat(value3.handle);
                            }
                        }
                    }
                }
            }
            else
            {
                bool flag7 = StylePropertyReader.getCursorIdFunc != null;
                if (flag7)
                {
                    StylePropertyValue value4 = this.GetValue(index);
                    defaultCursorId = StylePropertyReader.getCursorIdFunc(value4.sheet, value4.handle);
                }
            }
            UnityEngine.UIElements.Cursor v = new UnityEngine.UIElements.Cursor
            {
                texture         = texture,
                hotspot         = new Vector2(x, y),
                defaultCursorId = defaultCursorId
            };
            return(new StyleCursor(v));
        }