Hello!
A few days trying to find the answer how to create filled(pattern) sprite.
Maybe someone knows how to do it?
Many Thanks ![]()
Hello!
A few days trying to find the answer how to create filled(pattern) sprite.
Maybe someone knows how to do it?
Many Thanks ![]()
If by chance you’re looking for a pattern filled sprite for the purpose of creating terrain, then check out this awesomeness…
…if you like it, you can get it here…
I just wrote this to convert a sprite to a normalized quad.
public class SpriteTexture : MonoBehaviour {
public Sprite sprite;
public void Awake() {
Apply();
}
public void Apply() {
renderer.material.mainTexture = sprite.texture;
Debug.Log (sprite.texture.width + " " + sprite.texture.height);
Debug.Log (sprite.textureRect);
renderer.material.mainTextureScale = new Vector2(
sprite.textureRect.width/sprite.texture.width,
sprite.textureRect.height/sprite.texture.height
);
renderer.material.mainTextureOffset = new Vector2(
sprite.textureRect.x/sprite.texture.width,
sprite.textureRect.y/sprite.texture.height
);
}
}
I wrote this to place on a 9-sliced quad MeshFilter mesh but you could use it on a regular quad. You could then tweak the mainTextureScale to do tiling. By filled pattern you mean tiled right? If you just want to stretch a sprite to fill a space you can adjust its gameobject transform directly.
Thanks soooo much for help!