Esempio n. 1
0
 public void AddValue(ScalableImage value)
 {
     RegisterValue(m_ScalableImages, StyleValueType.ScalableImage, value);
 }
Esempio n. 2
0
        internal static bool TryGetImageSourceFromValue(StylePropertyValue propertyValue, float dpiScaling, out ImageSource source)
        {
            source = default(ImageSource);
            StyleValueType valueType      = propertyValue.handle.valueType;
            StyleValueType styleValueType = valueType;
            bool           result;

            if (styleValueType <= StyleValueType.AssetReference)
            {
                if (styleValueType != StyleValueType.ResourcePath)
                {
                    if (styleValueType == StyleValueType.AssetReference)
                    {
                        UnityEngine.Object @object = propertyValue.sheet.ReadAssetReference(propertyValue.handle);
                        source.texture     = (@object as Texture2D);
                        source.vectorImage = (@object as VectorImage);
                        bool flag = source.texture == null && source.vectorImage == null;
                        if (flag)
                        {
                            Debug.LogWarning("Invalid image specified");
                            result = false;
                            return(result);
                        }
                        goto IL_24E;
                    }
                }
                else
                {
                    string text  = propertyValue.sheet.ReadResourcePath(propertyValue.handle);
                    bool   flag2 = !string.IsNullOrEmpty(text);
                    if (flag2)
                    {
                        source.texture = (Panel.LoadResource(text, typeof(Texture2D), dpiScaling) as Texture2D);
                        bool flag3 = source.texture == null;
                        if (flag3)
                        {
                            source.vectorImage = (Panel.LoadResource(text, typeof(VectorImage), dpiScaling) as VectorImage);
                        }
                    }
                    bool flag4 = source.texture == null && source.vectorImage == null;
                    if (flag4)
                    {
                        Debug.LogWarning(string.Format("Image not found for path: {0}", text));
                        result = false;
                        return(result);
                    }
                    goto IL_24E;
                }
            }
            else if (styleValueType != StyleValueType.ScalableImage)
            {
                if (styleValueType == StyleValueType.MissingAssetReference)
                {
                    result = false;
                    return(result);
                }
            }
            else
            {
                ScalableImage scalableImage = propertyValue.sheet.ReadScalableImage(propertyValue.handle);
                bool          flag5         = scalableImage.normalImage == null && scalableImage.highResolutionImage == null;
                if (flag5)
                {
                    Debug.LogWarning("Invalid scalable image specified");
                    result = false;
                    return(result);
                }
                bool flag6 = dpiScaling > 1f;
                if (flag6)
                {
                    source.texture = scalableImage.highResolutionImage;
                    source.texture.pixelsPerPoint = 2f;
                }
                else
                {
                    source.texture = scalableImage.normalImage;
                }
                bool flag7 = !Mathf.Approximately(dpiScaling % 1f, 0f);
                if (flag7)
                {
                    source.texture.filterMode = FilterMode.Bilinear;
                }
                goto IL_24E;
            }
            Debug.LogWarning("Invalid value for image texture " + propertyValue.handle.valueType.ToString());
            result = false;
            return(result);

IL_24E:
            result = true;
            return(result);
        }
 public void AddValue(ScalableImage value)
 {
     this.RegisterValue <ScalableImage>(this.m_ScalableImages, StyleValueType.ScalableImage, value);
 }