Hi i need to acceso to an Script with Resourced.Load but this not wors, my image name is “Character” and the Sprite Name is “Chatacter_1”.
Thanks
Create a reference variable and store your sprite in it, then reference the variable when you want to load it. Unless you include more information or a bit of code then I cannot help you further.
Hi, same question I have. I will try to be more specific:
I create a Sprite Object: “ScreenBackground”
and I have in my Assets folder 2 images: “living.jpg” and “bedroom.jpg”.
I want to asign to my ScreenBackground objects one of those 2 images while running the game. For example when pressing 1 to show living and when pressign2 to show bedroom. How should we do that?
I created this script and stick it to my ScreenBackground object, but I still don’t know how to ‘load’ the image at runtime…
private SpriteRenderer mySprite;
// Use this for initialization
void Start () {
mySprite = GetComponent<SpriteRenderer>();
}
Thanks
I would recommend creating a prefab of the sprite and dragging that prefab into the resources folder. Then you can Instantiate the object Instantiate(Resources.Load(“TestSprite”)); If you wanted to you could also save the sprite as a GameObject variable to manipulate after creation: GameObject sprite = (GameObject)Instantiate(Resources.Load(“TestSprite”));
Well, I have like 80 scenes, so 80 images and in every scene i plenty of objects (images).
You are telling me to create a prefab for every image??
The problem is that i have the sprite and resources,but i cant load it from resoures and add to spriterenderer sprite. This not wotks.