2D Toolkit Forum
2D Toolkit => Support => Topic started by: SgtGriff on August 24, 2013, 04:17:32 pm
-
Hi, I'm a new user struggling with dynamic sprite loading/unloading.
For some context I am working on an old-school RPG-like battle scene, where different enemies have to be loaded depending on what the player has encountered. So I will have a large library of sprites that need to be picked from at run time.
How do you recommend loading, showing, and unloading Sprites at runtime? From what I can gather in the FAQ, the best way is to create a prefab and instantiate it. But after searching the forum I can't find a good example of how to do this. Can someone provide one?
-
You create a sprite and load it as you would any object in Unity.
Example here: http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html
Unity doesn't really care what prefab you're loading - if you create a prefab from a sprite, it will simply instnaite the prefab with all the other components on the prefab.
-
Wonderful, I've figured it out.
Your support is excellent, even for newbies. Thanks!