NutTextureUtils¶
Utilities created to help handling textures on general situations.
METHODS¶
CreateBaseTexture¶
Texture2D CreateBaseTexture(Color color)Texture2D CreateBaseTexture(Color color, int width, int height)Texture2D CreateBaseTexture(Color color, Vector2Int size)
Creates a base texture with the provided color and size. The texture will be automatically sized to one by one if no size is given.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | using NutTools.Utilities;
using UnityEngine;
public class MyClass: MonoBehaviour
{
public SpriteRenderer wall;
void MyMethod()
{
Texture2D tex = CreateBaseTexture(Color.white, 128, 128)
.ShiftRandomPixelsTowards(Color.cyan);
Sprite.Create();
}
}
|
CreateRandomNoiseTexture¶
Texture2D CreateRandomNoiseTexture(int width, int height, bool blackAndWhite = false)Texture2D CreateRandomNoiseTexture(Vector2Int size, bool blackAndWhite = false)
Creates a texture with the given size filled with random colors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | using NutTools.Utilities;
using UnityEngine;
public class MyClass: MonoBehaviour
{
public SpriteRenderer wall;
void MyMethod()
{
Texture2D tex = CreateRandomNoiseTexture(128, 128, false)
.MakeBlackAndWhite();
Sprite.Create(tex, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100.0f);
}
}
|
GET HELP¶
Join this Discord server to get help from the community, suggest new features, and vote on future updates!
See also
- NutTextureExtensions
- Sprite.Create