How to load Multiple Sprites by name in Unity?


This is an open to suggestions tutorial. Meaning, this is just one way that I’m doing it, if you have any suggestions, please please leave a comment.

It’s funny, I’ve asked this question on Twitter, I Google-d and even asked this guy from a Unity group on Facebook, and either they didn’t understand my question or they didn’t really give me the answer I wanted. Is it because I am thinking in the wrong way and we actually don’t need to do this?

Anyway, someone suggested that I just grab by the index of the “child” sprite in the multiple sprite… but I wouldn’t know what that index is, because this is not for animation, this is just simply treating a Multiple Sprite as a spritesheet.

Oh by the way, I used the awesome TexturePacker and its super useful TexturePackerImporter script to slice the Multiple Sprite in Unity.

So my Multiple Sprite is automatically sliced:

Screen Shot 2014-05-26 at 12.13.07 PM

I mean, sure I can drag the sliced sprites individually into my Scene, but did you know that if you try to use Resources.Load to well, load them by name, it wouldn’t work? And if you are going to suggest why don’t I just create each child as prefabs first, or… I have my reasons for needing Resources.Load.

For example:

GameObject bg1 = GUIMgr.getSpriteObject(Resources.Load<Sprite>(Sprites/Rewards/rewards_bg-iphone4));


GameObject bg1 = GUIMgr.getSpriteObject(Resources.Load<Sprite>(Sprites/rewards_bg-iphone4));

Those are going to return a NullReference.


By the way GUIMgr.getSpriteObject is just a helper method I have to return a Sprite as a GameObject that is added in the Scene:

public static GameObject getSpriteObject(Spritesprite)
GameObjectspriteObj = new GameObject(); =;
    SpriteRenderer spriteRenderer = spriteObj.GetComponent<SpriteRenderer>();
    spriteRenderer.sprite = sprite;

    return spriteObj;


Anyway, so I decided to do this instead, a Singleton named ResourceMgr:

using UnityEngine;
using System.Collections;

public class ResourceMgr : MonoBehaviour 
    private Hashtable m_sprites;

    #region Singleton
    private static ResourceMgr instance = null;
    public static ResourceMgr I
    {    get
        {    if (instance == null)
            {    GameObject resourceMgr = new GameObject();
       = ResourceMgr;

                resourceMgr.transform.position = Camera.main.transform.position;
            return instance;
    public static bool HasInstance
    {    get
        {    return (instance != null);

    void Awake()
    {    if (instance == null)
        {    instance = this;

            // ResourceMgr is loaded per scene to avoid keeping too much in memory

    // spritsheet needs to be initialized first and foremost
    // initSpritesheet only accepts Multiple sprites
    public void initSpritesheet(Sprite[] spritesheet)
        if (m_sprites == null
        {    m_sprites = new Hashtable();        

        foreach (Sprite sprite in spritesheet
            // sprites with same names are ignored
            {    m_sprites.Add(sprite.namesprite);

    public Sprite getSprite(string name)
        if (m_sprites.Contains (name)) 
        {    return (Spritem_sprites[name];        

        return null;


And this is how you use it:

using UnityEngine;
using System.Collections;

public class ResourcesTest : MonoBehaviour 
    public string[] m_filenames;

    void Start () 
        if(m_filenames != null)
            foreach(string filename in m_filenames)
                Sprite[] sprites = Resources.LoadAll<Sprite>(Sprites/ + filename);

        GameObject bg = GUIMgr.getSpriteObject(ResourceMgr.I.getSprite(rewards_bg-iphone4));


Just load up m_filenames with the filenames of the spritesheets, such as Rewards.

And voila! (Maybe I should combine the getSpriteObject with getSprite. Yup, I’ll do that.)

Comments, suggestions, violent reactions, just tweet me @purplelilgirl.


LostType Co-op – Pay what you want fonts


Description from the site:

The Lost Type Co-Op is a Pay-What-You-Want Type foundry, the first of its kind.

Founded by Riley Cran and Tyler Galpin, originally in a whirlwind 24 hour adventure to distribute a single typeface, Lost Type has blossomed into a full fledged foundry, distributing fonts from designers all over the world, with its unique model.

Users have the opportunity to pay whatever they like for a font, you can even type in ‘$0’ for a free download.

100% of funds from these sales go directly to the designers of the fonts, respectively.

Lost Type takes no cut of sales, and holds no funds.

LostType Co-op – Pay what you want fonts

How to create a game like Tiny Wings? Links


Tiny Wings is this adorable game by Andreas Illiger that involves this tiny bird who dream of flying.

It is extremely popular on the App store, and that is probably why lots of people wants to know how to make a game like it.

These are some links to tutorials and remake projects.

Sergey Tiknohov (@haqu) is working on a Tiny Wings remake project.

Ray Wenderlich wrote a tutorial based on Sergey’s project, which is divided into 2 parts. The tutorial uses Cocos2d and Box2d.

@jpsarda wrote a blog post on how to make the gorgeous hills in Tiny Wings using Cocos2d.

Emanuele Feronato wrote a tutorial on how to make the Tiny Wings terrain using Flash and Box2d.

    Packt Celebrates its 50th Oracle Book


    Throughout July Packt Publishing will be celebrating the release of its 50th Oracle book – cementing its reputation as one of the leading publishers in Oracle books.

    To mark this milestone Packt is offering the following discounts:

    ·         20% off all Oracle print books

    ·         30% off all Oracle eBooks

    Packt first started publishing Oracle books in 2006, and has since published best-sellers such as Getting Started With Oracle SOA Suite 11g R1 – A Hands-On Tutorial, Oracle Coherence 3.5 and Oracle Fusion Middleware Patterns.  And with more than 20 exciting new Oracle titles scheduled for 2011 this current success is only set to increase.

    Packt owes much of its success to its print-on-demand mantra which not only allows it to produce books on specialist areas, but enables a quick response to new developments in technology – which was recently demonstrated with Packt publishing the first ever book on GoldenGate, the Oracle GoldenGate 11g Implementer’s guide.

    Packt’s entire range of Oracle books is also available via PacktLib, Packt’s Online Library, and as part of Packt’s celebrations it’s offering you the chance to win a year’s subscription to PacktLib worth $220 click here for details:

    For further information on this, and other books published by Packt Publishing, please visit

    Review: Unity 3D Game Development by Example Beginner’s Guide


    Unity 3D Game Development by Example Beginner's Guide

    This is an excerpt of my previous blog post.

    This book is written by Ryan Henson Creighton aka Cassie the 5 yr old game developer’s dad. This book is about 380 something pages, and it takes you through Unity from the basics (as in what Unity is, what you can and cannot do *hint* MMOs unless you are really popular and has like a hundred friends or something). And then he teaches through examples, hence the title of the book. He also gives readers programming basics. All in all, the author is actually quite a fun read, because of his wit and humor, and it is nothing like my Computer Programming 1 professor, who tends to drone.

    Overall, I think this book is easy read, it’s not intimidating in such a way that it bombards you with information, code bits that you can’t even begin to grasp. I think that beginners, even those who have “never coded before” would find this book easy to digest, and might even be able to “build fun games”.

    For those who are interested in the book, you can check it here. The book actual offers samples codes and projects that you can download even if you haven’t bought the book, here.

    Unity on Kongregate and Unity books


    Unity is a game engine for making awesome 3D games for multiplatforms, such as iPhone, Android, PC, Mac, Wii, XBox 360, PS3 and web (did I just mention most of the common platforms, I think I did).

    Yup, you can build Unity games that run on the web. There have been a couple of Facebook games out there that are made using Unity, the first I can think of is the one with the Paintballs (what’s the title again?) Recently, okay, maybe last week, February 16, a contest on Kongregate just ended, it’s the Kongregate Unity Game Contest, and now, Unity games are also supported on Kongregate. So if you’re an Unity game dev, you can just toss some Unity games stuff there.

    Okay, time for some advertising, two very close friends of mine, also joined the contest, so, here’s me showing them some love by sharing it with you guys.

    Oh, to look for Unity games on Kongregate, just look at the Tags section, there’s a Unity tag, just click on that and go through, the hundreds of games there. I’m still trying to look for their game through that list.

    Oklay, found it!

    Must Get Candy

    The description of the game from the site by my friend, Chris (kcannon):

    You have an insatiable craving for candy causing you to run through candyland. Run for glory! Run for points!


    So far, they had 232 plays, and some comments are:

    I love this game, so addicting.

    I don’t know why I keep playing this.

    Is rare to see as a bear exploits for colliding with something, but the game is addictive

    So, yeah, I am plugging, it’s like Robot Unicorn, but cuter, since it have a bear, and candy, also since my friend, Len, crammed some art assets on my laptop with the Wacom Pen and Touch she gave me.

    Okay, enough about Kongregate.

    For game devs who are just starting out with Unity or plans to switch to Unity, there are a couple of Unity books out there by Packt Publishing:

    Unity 3D Game Development by Example Beginner’s Guide

    It’s written by Ryan Henson Creighton.

    According to the site:

    Overview of Unity 3D Game Development by Example Beginner’s Guide

    • Build fun games using the free Unity 3D game engine even if you’ve never coded before
    • Learn how to “skin” projects to make totally different games from the same file – more games, less effort!
    • Deploy your games to the Internet so that your friends and family can play them
    • Packed with ideas, inspiration, and advice for your own game design and development
    • Stay engaged with fresh, fun writing that keeps you awake as you learn


    Unity Game Development Essentials

    Written by Will Goldstone.

    According to the site:

    Overview of Unity Game Development Essentials

    • Kick start game development, and build ready-to-play 3D games with ease
    • Understand key concepts in game design including scripting, physics, instantiation, particle effects, and more
    • Test & optimize your game to perfection with essential tips-and-tricks
    • Written in clear, plain English, this book is packed with working examples and innovative ideas
    • This book is based on Unity version 2.5 and uses JavaScript for scripting


    So yeah, check those out!

    End of Unity post here.