Search Unity

Changing a Sprite-Object's sprite on runtime

Discussion in '2D' started by sima_likes_to_code, Nov 17, 2013.

  1. sima_likes_to_code

    sima_likes_to_code

    Joined:
    Oct 11, 2013
    Posts:
    1
    Hey there,

    I want to change a SpriteRenderer's sprite during runtime. Is there a find function, that returns a sprite, when I give it the name of the sprite?

    Code (csharp):
    1. Sprite my_sprite = Sprite.Find("my_sprite_0"); // <- something like that
    EDIT:
    To clarify: I don't want to find the SpriteRenderer (or the SpriteRenderer.sprite), I need the reference for the sprite itself, the .png by name (string).

    Thanks,
    Sima
     
    Last edited: Nov 17, 2013