Skip to main content

Resize

TextureUtilities.Resize()

public static Texture2D Resize(Texture2D texture, int targetX, int targetY)
ParameterTypeDefaultDescription
textureTexture2DThe Texture2D to rescale
targetXintTarget width
targetYintTarget height

Returns: Resized texture

A simple resize algorythm to scale up or down a Texture2D.


Example Usage

using UnityEngine;
using MikeDaBird.EZRecolor.Utilities;

class RotateTexture : MonoBehavior{
public Texture2D texture;
public Vector2 newScale;

// Scale a texture by a scale factor, both set within the Component
public Texture2D Scale(){
texture = TextureUtilities.Resize(texture, newScale.x, newScale.y);
return texture;
}
}