Quick Prefab Creation Plugin

This handy little script will create a prefab for you based on your selection of GameObjects. Just make sure to save it as a JavaScript in your Editor folder.

// generate a prefab from the selection

@MenuItem ("Project Tools / Make Prefab #&_p")

static function CreatePrefab ()
{

var selectedObject : GameObject[] = Selection.gameObjects; // selection from the scene view

// loop through our selection
for (var go : GameObject in selectedObject)
{
var name : String = go.name; // store the name of our selection
var localPath : String = "Assets/" + name + ".prefab"; // create the path for the prefab
// check for object in project
if (AssetDatabase.LoadAssetAtPath(localPath, GameObject))
{
// check for user choice
if (EditorUtility.DisplayDialog ("Caution", "Prefab already exists. Do you want to overwrite?", "Yes", "No"))
{
createNew (go, localPath); // creating a new prefab
}
}
else
{
createNew (go, localPath); // creating a new prefab
}
}
}
// Create a new prefab
static function createNew ( selectedObject : GameObject, localPath : String)
{
var prefab : Object = PrefabUtility.CreateEmptyPrefab (localPath); // store prefab
PrefabUtility.ReplacePrefab (selectedObject, prefab); // set prefab to prefab
AssetDatabase.Refresh(); // refresh the database

DestroyImmediate (selectedObject); // Remove the selected object
var clone : GameObject = PrefabUtility.InstantiatePrefab(prefab) as GameObject; // replace object with prefab
}

Generate Project Folders Script

When creating a new project, use this simple script to generate all your folders:

// generate folders in our project
import System.IO;

@MenuItem ("Project Tools / MakeFolders #&_z")
// menuItem reads the first static function
static function MakeFolder()
{
GenerateFolders();
}

static function GenerateFolders ()
{

var projectPath : String = Application.dataPath + "/"; // store the path for the folders

// creating the folders
Directory.CreateDirectory(projectPath + "Audio");
Directory.CreateDirectory(projectPath + "Materials");
Directory.CreateDirectory(projectPath + "Meshes");
Directory.CreateDirectory(projectPath + "Resources");
Directory.CreateDirectory(projectPath + "Scripts");
Directory.CreateDirectory(projectPath + "Shaders");
Directory.CreateDirectory(projectPath + "GUI");
Directory.CreateDirectory(projectPath + "Textures");
Directory.CreateDirectory(projectPath + "Scenes");
Debug.Log ("Folders Created");

AssetDatabase.Refresh ();

}

Interview With the Tornado Twins

I recently had a chance to talk with Efraim and Ruben Meulenberg (the Tornado Twins). The Tornado Twins are media masters; they are “involved in any type of media production, from electronic music to games, print media and art.” They have a number of video tutorials available on Youtube to help you make games and music.

tornado-twins

Welcome, Tornado Twins! So, when did you start making games?

We started making games at age 10 with a 3d software called “Klik & Play“. Very basic stuff but it started getting us interested in all aspect of gamedev. Two years later we were coding in C++ using the Genesis3D engine. From there we’ve hit all major indie engines under the sun and we still play around with a lot of them.

How did you find out about Unity3D?

Unity was relatively unknown in 2006/2007 and was Mac-only. We liked it so much that we turned our whole office into a mac-only-shop and jumped on the Unity train.

Cool. What advice would you give to those just starting out with game development, especially those on a small budget?

If you have a small budget you have two options: make/raise money for your project or do everything yourself. Even with a small off-time team you better count on doing everything yourself. Many such teams fail.
Making a competitive small game costs at least 100k of either investment or time.
I hope our tutorials on YouTube can help a lot of people in this regard, to show what some good avenues are to take as well as ease up the overwhelming options in a game engine and narrow it down.

Interesting. So, what games are you currently working on?

We’re turning the whole Bible into a video game (this is a high end game with a multi-year investment from our team) as well as working on a system that helps people make FPS games fast. We’ll probably release that system for free on January first through TornadoTwins.com.

Sounds good. What other projects besides games are you working on?

We have started businesses in all areas of media development, including games, music, books and audio.

What do you think about the new Unity 4?

Unity 4 is great. Mecanim is a blast to plug the bugs in common animation clip approaches and the other features are epic as well. But really Mecanim is the big deal of 4.0 in our opinion.
Let’s hope that the next release has some awesome audio (FMOD-style) features and that will make our day… erhm… year.

unity4

Unity 4 sure is great. What are your thoughts on other game engines, like UDK?

Love them! We love them all. Every one needs to find their own tools for the job. For us that’s Unity right now.

Lastly, where do you see the Tornado Twins headed in the future? Where do you plan to go and what do you plan to do? 

Our next plans are a little secret until January first. We’ll always help other game developers as well as develop our own titles. People can follow us through the free newsletter on TornadoTwins.com. One thing is for sure: we’ll be releasing free new tutorial videos again each week. That’s all we can say!

Making Custom Gizmos

In this post, I will show you how to make a custom gizmo to be displayed over game objects in Unity. For instance, I have a bunch of collectible gems in my game, and I want to be able to see them easily, though they are kind of small. So I’ll need to make a gizmo.

First, you need an image with an alpha channel. Here’s an example:

gem gizmo gimp

Okay, make sure you export your image into Unity. You should probably make a folder in your Unity project called “Gizmos”. Next create a script. It’s as simple as 1, 2, 3 lines of code.

function OnDrawGizmos () {
    Gizmos.DrawIcon (transform.position, "gemGizmo.png");
}

That’s in JavaScript. Let me give it to you in C# as well, in case you’re one of those C# guys.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void OnDrawGizmos() {
        Gizmos.DrawIcon(transform.position, "gemGizmo.png");
    }
}

So there you have it.

Now, let me tell you something. That is the hard way to do it. The code way. The long way. As of Unity 3.5x, you can select your game object, look at the top left corner in the Inspector, and click the little icon with the arrow. Then click Other and choose your texture.

So THERE you have it.