Exemplo n.º 1
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));
        }