- Home /
Efficient Dynamic Sprites
I'm working on an item generator system to generate random loot. Everything works fine, I don't have any issues. What I'm wondering about is, what is the best and most efficient method of calling on my sprites? I created a Static file to handle loot generation, which for obvious reasons can't really contain any permanent data, so I have come to the part where I make the generator ask for an icon, I enjoy the ability in Unity to drag and drop my stuff in inspector,, but I don't think that is the best route for dynamically loading sprites by simply having all references on one MonoBehaviour. So my options are a List of filenames, a MonoBehaviour script with sprite arrays, or.... I can't think of another efficient method. Anyone got ideas?
Answer by RobAnthem · Dec 30, 2016 at 11:29 PM
This was my Solution... please tell me there is a better way.
public Sprite GetIcon(GameData.EquipType iconType)
{
return (Resources.Load(ItemSprites[UnityEngine.Random.Range(0, ItemSprites.Length)]) as GameObject).GetComponent<SpriteRenderer>().sprite;
}
Also ignore EquipType, it is the next step of implementing this system, but I already dislike where this is going.
Answer by Benbolion · Jan 19, 2017 at 05:19 AM
I dont think i can help you much, but i am currently working on Item-Sprite combination. What i am still working with, is an ID field in an item class refere to the index of a List of Sprites on a monobehaviour script. But this is as you first stated, not ideal.
i hope someone of knowledge could share their experience. B
Your answer
Follow this Question
Related Questions
Sprite Manager 1 Answer
How to call sprite at run time 3 Answers
SpriteManager 1 : Custom Material 1 Answer
Sprite Manager 2: 3GS & iOS 5-6 textures corrupt 0 Answers
SpriteManager (2) VS EZSPrite 0 Answers