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

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.

Continue reading “Indie Speed Run 2013: “From Strawberry” Dev Post”