Hello Guest

Author Topic: Basic questions on dynamic sprite creation/destruction  (Read 5469 times)

SgtGriff

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Basic questions on dynamic sprite creation/destruction
« 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?
« Last Edit: August 24, 2013, 04:19:17 pm by SgtGriff »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Basic questions on dynamic sprite creation/destruction
« Reply #1 on: August 24, 2013, 09:03:58 pm »
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.

SgtGriff

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Basic questions on dynamic sprite creation/destruction
« Reply #2 on: August 24, 2013, 09:09:16 pm »
Wonderful, I've figured it out.

Your support is excellent, even for newbies. Thanks!