How to create gradient backgrounds in Unity?


Someone asked how to create gradient backgrounds in Unity on Unity Answers and Eric5h5 gave an awesome answer:

Screen Shot 2015-01-30 at 9.58.27 AM

This 1×2 pixel picture in Photoshop…

Screen Shot 2015-01-30 at 10.00.25 AM

Can turn into this:

Screen Shot 2015-01-30 at 10.01.37 AM

Pretty awesome, right? Thanks Eric5h5!


Things to note when committing your Unity Project to GIT


In your Unity Project:

  1. Go to Edit > Project Settings > Editor.
  2. Set Version Control Mode as Visible Meta Files. 
  3. Set Asset Serialization Mode as Force Text.

In your GIT Project:

    1. Set .gitignore
    2. If you’re using SourceTree, go to Settings > Advanced > Repository-specific ignore list > Edit.

Then you’re good to go! 🙂

Yeti Crab also wrote a good tutorial on how to use GIT with Unity without using command line (they used SourceTree and BitBucket).

#indiesvspewdiepie weekend jam

Dev, Games

So I haven’t done a game jam in a while (after I failed my #nar8). And I wasn’t really planning on doing #indiesvspewdiepie.

But then my lil sis and I woke up on Saturday and saw that one of our colleagues were doing it, and we’re like yah, we should do it too.

But first French Toast with eggs and bacon, sprinkles (because why wouldn’t you add sprinkles. actually, it’s my first time adding sprinkles on my toast, and yah, you wouldn’t, you shouldn’t).

We decided to make a fighting game starring fat animals. Because we saw that really cute video starring fat balloon animals.

My little sis sketched this:


We started with a box model, of the basic game play. We simplified the controls to just tapping two keys alternately really really quick.

Oh yah, and as usual, I used Unity as my game engine, I was only on Basic, because I couldn’t remember which of my accounts had the Pro license.

Literally a box model:

Screen Shot 2014-11-24 at 10.37.28 PM

One thing that we have been doing at work is using box models to test out basic gameplay. If it’s fun during the box model, you should be good to go. And using box models is a good way to test out asset sizes etc.

And then:

Screen Shot 2014-11-24 at 10.39.14 PM

I started with a 2 player mode, and then added a 1 player vs com mode.

And pandas have colors now:

Screen Shot 2014-11-24 at 10.41.11 PM

And then we decided that we’ll just stick to pandas. Just pandas. Because pandas are the cutest animals ever.

And then while my lil sis was drawing everything, I was voicing pandas. Saying things like “I’m so fluffy” and “I hate you.”

And then lots of UI:

I placed in the cool background music that I had been using for all my previous game jams.

Some more tweaks and we were done.

And we uploaded it.

End of Saturday.

On Sunday, we did laundry, and I baked cupcakes.

With sprinkles, obviously.


And I was going through the Game Jam Rules again, and read that all audio assets needed to be done within the 72 hours as well.

So I recorded some more nonsense as our background music.

And uploaded it again.

And since we still had a lot of time on our hands, we also made a trailer for our game:

By the way, the name of our game is “Fist of Furry”.

It’s on GameJolt:


Voting just started, so please vote for us. Please and thank you.

Voting just ended and results are in! And Fist of Furry is #39 out of 700+ games! We didn’t win, but it’s pretty okay.

The important part is finishing a game in less than a weekend, and for people to play our game and appreciate its cuteness and soundfx.


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.

How to Create Unity Android Plugins?


Disclaimer: This is based on FastEgg’s Tutorial

Sometimes we need to create Plugins to easily use external frameworks such as Ad Networks in Unity.


1. Create new Android Application Project

* Application Name, Project Name should refer to the specific plugin (admob for a plugin for AdMob)

2. Add Additional Libraries

  • right click on Project and select “Properties”
  • navigate to “Java Build Path”
  • select “Libraries” tab
  • click on “Add External JARs”
  • add Unity’s “classes.jar” (located at <UnityInstallPath>\Editor\Data\PlaybackEngines\AndroidPlayer\bin\classes.jar)
  • add other JARs that are required by the plugin (such as AdMob’s jar)

Unity’s classes.jar

  • it is found in the installation folder
  • C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\bin on Windows
  • /Applications/Unity/PlaybackEngines/AndroidPlayer/bin on Mac

  • select “Order and Export”
  • tick all external JARs to make sure that they will be exported together with the new JAR file

3. Code the Plugin

  • create new class with the same name as the project (such as
  • make sure to give it the package name of your plugins package
  • create a Constructor
  • can refer to activity using UnityPlayer.currentActivity
package com.example.AdMob
public class AdMob
{ private Activity activity; //Store the android main activity

  public AdMob()
  { activity =UnityPlayer.currentActivity;

4. Export Plugin

  • right click on project and select “Export”
  • in the Export Window, select “Java/JAR file”
  • in Jar Export Window, make sure current project is ticked
  • set export location to our Unity Project’s “Assets\Plugins\Android folder”
  • name plugin (such as AdMob.jar)
  • the wizard will pack the jar file, making it available for Unity

* sometimes plugins require additional JARs to be included our Unity Project’s “Assets\Plugins\Android folder” (such as the AdMob SDK)

5. Call Plugin From Unity

  • create a new MonoBehaviour script in Unity, and name it closely to your plugin (such as AdMobController)
#pragma strict
public class AdMobController extends MonoBehaviour
{ function Awake()
  • to activate our new plugin, we need to create a new AndroidJavaObject, and by using our package name, we can have it cast to the type we created in our JAR file:
#pragma strict
public class AdMobController extends MonoBehaviour
{ private static var jo:AndroidJavaObject;
  function Awake()
   jo =newAndroidJavaObject("com.example.admob.AdMob");

6. Modifying the Manifest

  • Unity will usually create it’s own AndroidManifest.xml file when packaging your project, but also allows for you to override the one it creates with one you define inside of the Assets/Plugins/Android folder
  • you can either create one from scratch, or copy over the default one that Unity has created for your project
  • to get the default, make a build in Unity, and let it complete and save. Then look in your projects temp/stagingarea folder. There should be a AndroidManifest.xml file generated for you. Copy that to your projects Assets/Plugins/Android folder, and edit it using MonoDevelop
  • modify the Manifest file to include things required by your plugin (such as requires Internet): <uses-permission android:name=”android.permission.INTERNET” />
  • save changes


If you set your Android Application as Library, it’s Android Manifest will automatically be merged with any existing ones in your Unity project.

To set your project as Library, go to the project’s Properties > Android and tick Is Library, and click Apply.

It will add a file to your project, make sure to include that in your jar file.

Screen Shot 2015-01-09 at 4.57.34 PM

7. Testing

  • some Android related things (such as Ads) doesn’t show up in the Unity Editor, so you’d need to build and run on an Android device to test
  • you can use adb logcat in Terminal to debug while running on Android device
  • Ctrl+C stops logcat

That’s it!

Unity 3D Game Development by Example Video Review


Unity 3D Game Development by Example is a Video lecture by Adam Maxwell (Packt has videos now, apparently).

It has 8 sections, each around 20 minutes, which covers the basics of Unity 3D game engine.

The author or narrator explains everything from the very basic things, such as how Unity’s user interface looks like, where to find everything, to more complex things like how to write scripts, how to make Title screens and Menus, how to save and load data for your games through examples.

The narration is paired with “slides” that in bullet points or diagrams that help explain some topics. And of course, the video also demonstrates concepts using the game engine itself, so it’s easy for listeners to follow and understand.

The narration for me though, is a little flat, but it’s still better than reading books, and simply following through screenshots.

For beginners, I think this video lecture is a good place to start. But people who are already familiar with Unity, this video doesn’t offer much more.

You can check out the video lecture on Packt’s website or check out some sample sections on YouTube.

Indie Speed Run 2013: “From Strawberry” Dev Post


Indie Speed Run is like a game jam, but slightly different, because one, you don’t have to be at a physical location (which is great, so at least you get to sleep in your own bed, if ever, between breaks) and it has a theme and an element that you need to incorporate into your game.

This is my second year doing Indie Speed Run, last year was my first (also my first ever game jam). Instead of grouping with my friends who were in the Philippines and working together virtually through Google Hangouts like I did last year, I decided to group up with my sisters instead, and we worked on the game together from our apartment. I’m just lucky to be a programmer that have 2 sisters who are artists.

How to add Facebook to Unity Android?


I searched for this before, but couldn’t find a solution that was easy or cheap (by cheap, I mean free).

Pavel Kultyshev (@getencapsulated) also wrote a blog post, sharing messages on Twitter or Facebook by following the link in the browser of a mobile device or by opening the client app on this device. I haven’t tried this approach though, because I’m looking for something more “native” to Unity.

If you’d like an easy drag and drop solution and willing to spend, then there are a couple of available plugins: the aptly named Facebook Plugin for Android by Mida Mobile (for $20), Unishare, that also includes Twitter, LinkedIn, Sina Weibo, etc. (it’s $25, I don’t know how good it is, but for 5 more dollars you get way more social stuff, sounds pretty good), and of course, Prime31 also has one, it includes Twitter too (for $65 though).

Macaronics (phardera) also wrote a blog post on how to do this using Android Plugins: (it’s in Chinese though). Don’t worry, the entire project is available in phardera’s github (

Mini Tutorial: How to localize your Unity game to Chinese? (Step 1)


UPDATE: Fixed the link to FontForge Installer

I get a lot of interesting answers to problems on the Unity forums, even if it’s in the Showcase threads.

Like for example, on how to localize your Unity games, particularly. In case you didn’t know, there are sooo much Chinese characters, so much that it couldn’t possibly fit in a 2048×2048 font texture. So the solution to that according to Aby Escape’s (do check out their game on iTunes, it’s free and looks pretty fun: Juan Luis (

-Take a font file (ttf) and remove all the characters that you don´t use on your game.

For this solution there are a link on unifyComunity:…_TrueType_font

But this is a partial solution, because for me, if I select CJK characters selecting by script, there are missings character on my game.

So I want to select ONLY the characters that my game using.

You can check out his code in this forum thread (

But his script is in Javascript, and prints output on the console, according to Juan Luis there are limits with the output of the unity Console, so you can split the string, or print it on a file.

So I wrote an Unity Editor script based on his that accepts a Text file that contains all the characters that you’d need in your game, and then it outputs a Text file containing a script that you can just copy paste in FontForge.


using UnityEngine;
using UnityEditor;
using System.Collections;

public class ConvertTextToUnicode: EditorWindow
    TextAsset inputText;

    [MenuItem (“Project Tools/Convert Text to Unicode”)]
    static void Init ()
    {    ConvertTextToUnicode window = (ConvertTextToUnicode)EditorWindow.GetWindow (typeof (ConvertTextToUnicode));

    void OnGUI ()
    {    inputText = EditorGUILayout.ObjectField(“Input Text”, inputText, typeof(TextAsset)) as TextAsset;

        {    Convert();

    void Convert()
    {    string inputTextString = inputText.text;

        string[] inputTextArr = inputTextString.Split(‘n’);

        string finalScript = “”;

        for(int i=0; i< inputTextArr.Length; i++)
        {    string script = “SelectMoreSingletons(“;

            string line = inputTextArr[i];

            for(int j=0; j < line.Length; j++)
            {    string unicode = System.Convert.ToInt32(line[j]).ToString(“X”);

                   if(unicode.Length == 1)
                    unicode = “U+000” + unicode;
                else if(unicode.Length == 2)
                    unicode = “U+00” + unicode;
                else if(unicode.Length == 3)
                    unicode = “U+0” + unicode;
                else if(unicode.Length == 4)
                    unicode = “U+” + unicode;

                if(!script.Contains(unicode) && !finalScript.Contains(unicode))
                {    script = script + “"”+ unicode + “"” +  “,” ;

                   if((j+1)%10 == 0)
                {    script =  script + “"” + “U+0020");”;

                    if(i == 0)
                    {    finalScript = script;
                    }    else
                    {    finalScript = finalScript + “n”+  script;

                       script = “SelectMoreSingletons(“;

            script =  script + “"” + “U+0020");”;
            finalScript = finalScript + “n”+  script;

        System.IO.File.WriteAllText(“Assets/””Converted.txt”, finalScript);

Place this script in the Assets/Editor folder of your Unity project.

The Unity Wiki ( has very detailed instructions for the rest of the steps.

Step 1 is Download and Install FontForge (, but FontForge no longer provides binary packages. A little Google-ing found me this link: The site is still under construction it seems, but the linked FontForge Beta Package works.

Step 2 is Get a unicode font, e.g. Arial Unicode MS. The ArialUni.ttf font can be found in Windows in C:WINDOWSFont, or if you’re on a Mac, go to Font Book, select the font you want, right click and then Show in Finder.

And then follow the rest of the steps ish for extracting a specific subrange of characters.

1. Open the font in FontForge

Instead of their step 2 and 3, go to File and then Execute Script.


A window with a text field is going to pop up, just copy and paste your converted characters script in there and click OK.


And then go back to following the instructions on Unity Wiki:

4. Invert your selection by going to Edit->Select->Invert Selection

5. Remove these unwanted symbols by going to Encoding->Detach & Remove Glyphs. This may take some time – but when it is finished you will notice that all the highlighted font cells have now been crossed out.

Operation in progress example (this may take sometime, try not to touch anything FontForge can be a bit unstable):

Operation complete example, all the selected symbols have been replaced with crosses:

You may find some of your character cells have blue in them, I don’t know what this means but it has not caused me any problems:

6. Compact your new font to only the useable symbols by going to Encoding->Compact.
Compacted font example:

7. Generate the TTF font by going to File->Generate Fonts.
The only option I change is the export type to TrueType.
8. Import into Unity, sacrifice something to the God of FontForge and enjoy.

Yes, sacrificing to the God of FontForge is a must.

And that’s it, you have a new font with Chinese characters that fits into a 2048×2048 font texture.

Other tips: How to find out the language of your iPhone when using Unity?, because Unity can’t seem to differentiate Traditional Chinese from Simplified Chinese (yes, there is a difference).

Ultimate List of Purplelilgirl Tutorials


Throughout the year(s) I have accumulated a number of mini tutorials, code bits and links, but they are just scattered in this blog like.. um.. sprinkles? And they need to be organized. So here, I am going to attempt to create a link list:




Misc. iOS and game development-related:

Book reviews and overviews:

Games, apps reviews and self-promotions:

Gamasutra blogs and reblogs: