how to select/change which sprite set is used from a multiple set spritesheet?
game simple : Muffin Knight Gameplay Trailer - YouTube
how to select/change which sprite set is used from a multiple set spritesheet?
game simple : Muffin Knight Gameplay Trailer - YouTube
This is what works for me in this scenario. This way you can get all the Sprites inside the single Texture., First, you will need to get a “Resource” folder inside the “Asset” folder (Note: Anything within the Resource folder can be gathered within the script).
Here is an example using
public class CursorScript : MonoBehaviour
{
private SpriteRenderer spriteRender;
private Sprite[] renderToSprite;
// Start is called before the first frame update
void Start()
{
//Get the "SpriteRender Component to modified the image of the cursor.
spriteRender = gameObject.GetComponent<SpriteRenderer>();
//Set the name of the Image Sprite.
string multiSpriteName = spriteRender.sprite.texture.name;
//Set the location A.K.A the path of where the multi-Sprite Image is located
(Note: The image has to be inside the "Resource" Folder).
string path = "Sprites/UI/";
//Get all Sprites that fit the requirements to cast into the "RenderToSprite".
renderToSprite = Resources.LoadAll<Sprite>(path + multiSpriteName);
//Render a new sprite selected in the "renderToSprite[Array]".
spriteRender.sprite = renderToSprite[1];
}
}
This is what works for me in this scenario. This way you can get all the Sprites inside the single Texture.