- Home /
Convert String to Sprite
Hi, I need to convert a string to a sprite.
I tried making an array of 99 sprites, but it causes the scene load time to be slow (this scene is loaded often)
I decided to instead, have an array of 99 strings, pull a string from the array and convert it to sprite.. But can't seem to find anywhere how to do this:
Pseudocode:
String imagename = "Thetestimage";
...
gameObject.Sprite = imagename;
instead of (which is the way I think most people will suggest doing this)
public Sprite spritename ;
...
gameObject.Sprite = spritename;
Thanks for you time.
Answer by jni97 · Jan 07, 2016 at 12:42 PM
If you already have your sprites in your Resources folder, you can just use Sprite = Resources.Load(spritename);
Your answer
Follow this Question
Related Questions
2 single sprites in array increase draw calls infinitely!? 1 Answer
Strings arrays in strings array? 1 Answer
How to detect that array items are triggered? 1 Answer
How to load all my sprites in my folder and put them in an array. 2 Answers
Cannot convert float to int when only using floats (C#) 3 Answers