DrawSprite() public static méthode

public static DrawSprite ( Sprite sprite, Rect drawArea, Color color ) : void
sprite UnityEngine.Sprite
drawArea UnityEngine.Rect
color Color
Résultat void
        public static void DrawSprite(Sprite sprite, Rect drawArea, Color color)
        {
            if ((Object)sprite == (Object)null)
            {
                return;
            }
            Texture2D texture = sprite.texture;

            if ((Object)texture == (Object)null)
            {
                return;
            }
            Rect rect  = sprite.rect;
            Rect inner = rect;

            inner.xMin += sprite.border.x;
            inner.yMin += sprite.border.y;
            inner.xMax -= sprite.border.z;
            inner.yMax -= sprite.border.w;
            Vector4 outerUv = DataUtility.GetOuterUV(sprite);
            Rect    uv      = new Rect(outerUv.x, outerUv.y, outerUv.z - outerUv.x, outerUv.w - outerUv.y);
            Vector4 padding = DataUtility.GetPadding(sprite);

            padding.x /= rect.width;
            padding.y /= rect.height;
            padding.z /= rect.width;
            padding.w /= rect.height;
            SpriteDrawUtility.DrawSprite((Texture)texture, drawArea, padding, rect, inner, uv, color, (Material)null);
        }
Exemple #2
0
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            RawImage rawImage    = base.target as RawImage;
            Texture  mainTexture = rawImage.mainTexture;

            if (!(mainTexture == null))
            {
                Rect outer = RawImageEditor.Outer(rawImage);
                SpriteDrawUtility.DrawSprite(mainTexture, rect, outer, rawImage.uvRect, rawImage.canvasRenderer.GetColor());
            }
        }
Exemple #3
0
        /// <summary>
        /// Draw the Image preview.
        /// </summary>

        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            Image image = target as Image;
            if (image == null) return;

            UnityEngine.UI.Sprite sf = image.sprite;
            if (sf == null) return;

            if (sf.type == Sprite.Type.Sprite && sf.sprite != null)
                SpriteDrawUtility.DrawSprite(sf.sprite, rect, image.canvasRenderer.GetColor());
        }
Exemple #4
0
        /// <summary>
        /// <para>Custom preview for Image component.</para>
        /// </summary>
        /// <param name="rect">Rectangle in which to draw the preview.</param>
        /// <param name="background">Background image.</param>
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            RawImage target      = base.target as RawImage;
            Texture  mainTexture = target.mainTexture;

            if (mainTexture != null)
            {
                Rect outer = Outer(target);
                SpriteDrawUtility.DrawSprite(mainTexture, rect, outer, target.uvRect, target.canvasRenderer.GetColor());
            }
        }
Exemple #5
0
        /// <summary>
        ///   <para>Custom preview for Image component.</para>
        /// </summary>
        /// <param name="rect">Rectangle in which to draw the preview.</param>
        /// <param name="background">Background image.</param>
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            RawImage target      = this.target as RawImage;
            Texture  mainTexture = target.mainTexture;

            if ((Object)mainTexture == (Object)null)
            {
                return;
            }
            Rect outer = RawImageEditor.Outer(target);

            SpriteDrawUtility.DrawSprite(mainTexture, rect, outer, target.uvRect, target.canvasRenderer.GetColor());
        }
Exemple #6
0
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            Image image = base.target as Image;

            if (!(image == null))
            {
                Sprite sprite = image.sprite;
                if (!(sprite == null))
                {
                    SpriteDrawUtility.DrawSprite(sprite, rect, image.canvasRenderer.GetColor());
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// <para>Custom preview for Image component.</para>
        /// </summary>
        /// <param name="rect">Rectangle in which to draw the preview.</param>
        /// <param name="background">Background image.</param>
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            Image target = base.target as Image;

            if (target != null)
            {
                Sprite sprite = target.sprite;
                if (sprite != null)
                {
                    SpriteDrawUtility.DrawSprite(sprite, rect, target.canvasRenderer.GetColor());
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Draw the Image preview.
        /// </summary>
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            RawImage rawImage = target as RawImage;
            Texture  tex      = rawImage.mainTexture;

            if (tex == null)
            {
                return;
            }

            var outer = Outer(rawImage);

            SpriteDrawUtility.DrawSprite(tex, rect, outer, rawImage.uvRect, rawImage.canvasRenderer.GetColor());
        }
        /// <summary>
        ///   <para>Custom preview for Image component.</para>
        /// </summary>
        /// <param name="rect">Rectangle in which to draw the preview.</param>
        /// <param name="background">Background image.</param>
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            Image target = this.target as Image;

            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return;
            }
            Sprite sprite = target.sprite;

            if ((UnityEngine.Object)sprite == (UnityEngine.Object)null)
            {
                return;
            }
            SpriteDrawUtility.DrawSprite(sprite, rect, target.canvasRenderer.GetColor());
        }
        /// <summary>
        /// Draw the Image preview.
        /// </summary>

        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            Image image = target as Image;

            if (image == null)
            {
                return;
            }

            Sprite sf = image.sprite;

            if (sf == null)
            {
                return;
            }

            SpriteDrawUtility.DrawSprite(sf, rect, image.canvasRenderer.GetColor());
        }
        /// <summary>
        /// Draw the Image preview.
        /// </summary>

        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            RawImage rawImage = target as RawImage;
            Texture  tex      = rawImage.mainTexture;

            if (tex == null)
            {
                return;
            }

            Rect outer = rawImage.uvRect;

            outer.xMin *= rawImage.rectTransform.rect.width;
            outer.xMax *= rawImage.rectTransform.rect.width;
            outer.yMin *= rawImage.rectTransform.rect.height;
            outer.yMax *= rawImage.rectTransform.rect.height;

            SpriteDrawUtility.DrawSprite(tex, rect, outer, rawImage.uvRect, rawImage.canvasRenderer.GetColor());
        }
        /// <summary>
        /// Draw the Image preview.
        /// </summary>

        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            AltSketchPaint paint = target as AltSketchPaint;
            Texture        tex   = paint.mainTexture;

            if (tex == null)
            {
                return;
            }

            Rect outer = paint.UVRect;

            outer.xMin *= paint.rectTransform.rect.width;
            outer.xMax *= paint.rectTransform.rect.width;
            outer.yMin *= paint.rectTransform.rect.height;
            outer.yMax *= paint.rectTransform.rect.height;

            SpriteDrawUtility.DrawSprite(tex, rect, outer, paint.UVRect, paint.canvasRenderer.GetColor());
        }
 public static void DrawSprite(Sprite sprite, Rect drawArea, Color color)
 {
     if (!(sprite == null))
     {
         Texture2D texture = sprite.texture;
         if (!(texture == null))
         {
             Rect rect  = sprite.rect;
             Rect inner = rect;
             inner.xMin += sprite.border.x;
             inner.yMin += sprite.border.y;
             inner.xMax -= sprite.border.z;
             inner.yMax -= sprite.border.w;
             Vector4 outerUV = DataUtility.GetOuterUV(sprite);
             Rect    uv      = new Rect(outerUV.x, outerUV.y, outerUV.z - outerUV.x, outerUV.w - outerUV.y);
             Vector4 padding = DataUtility.GetPadding(sprite);
             padding.x /= rect.width;
             padding.y /= rect.height;
             padding.z /= rect.width;
             padding.w /= rect.height;
             SpriteDrawUtility.DrawSprite(texture, drawArea, padding, rect, inner, uv, color, null);
         }
     }
 }
 public static void DrawSprite(Texture tex, Rect drawArea, Rect outer, Rect uv, Color color)
 {
     SpriteDrawUtility.DrawSprite(tex, drawArea, Vector4.zero, outer, outer, uv, color, null);
 }