Blog

Unity Editor Lesser Known Features

December 19, 2011 by Devin Reimer

The other day I discovered a sweet feature in Unity that has existed for a long time. With this I decided to create a short list of some cool features in the Unity editor that you might not be aware of.

1) Inspector Lock – At the top of the inspector panel there is a small ‘lock’ icon. This locks the inspector to currently selected GameObject. This is great for things like adding GameObjects to arrays. 
http://unity3d.com/support/documentation/Manual/Inspector%20Options.html

2) Multiple Inspectors – Click the ‘context menu’ icon (next to the ‘lock’ icon) in the inspector. In that drop down, select ‘Add Tab’, then ‘Inspector’. Use in conjunction with inspector lock to become a productivity machine.
(via @AngryAnthttp://twitter.com/#!/AngryAnt/statuses/142724785384865793)

3) Project and Hierarchy Search By Type – Not only can you search for items by name, but also by type. To do this, click the ‘Search’ icon drop down and select ‘Type’. Or to be more efficent, simply type ‘t:type’. Ex: t:texture, t:material, etc.
(via @aras_phttp://twitter.com/#!/aras_p/status/143010880706183168)

4) Inserting and Deleting Items From Arrays In Inspector – Populating arrays using the Unity editor is very handy, that is until you realize that you need to remove or add an item in the middle of the array. It might appear that there is no way to do this, but there is. To duplicate an item, select it and hit Ctrl-D (Windows), Command-D (Mac). To delete an item, hit Shift-Delete twice (once to clear, second time to remove it)

5) Creating New Line in Inspector Text Input – On a Mac simply hit Option-Return to create a new line. On Windows this functionality is…’missing’. Normally you would have to copy and paste a new line for somewhere else. :(
As this is kind of lame, I wrote a Unity editor script to fix this. Simply create a folder in your project called ‘Editor’ and drop this script (InsertNewLine.cs) into it.
Now you can simply hit Alt-Enter on Windows to create a new line. :)
http://answers.unity3d.com/questions/43424/multi-lining-or-line-breaks-for-the-inspector-wind.html & http://blog.almostlogical.com/resources/InsertNewLine.cs

6) Creating a Prefab Quickly – Simply create your GameObject in the Hierarchy and drag it down into the Project panel. Instant prefab!
http://blogs.unity3d.com/2011/03/25/ninjacamp-iii-quick-prefabs/

7) Editing Primitive Collider Dimensions in Scene View – Select a GameObject with a collider and hold down the shift key. Small greens squares will appear in the Scene View which you can then manipulate.
http://unity3d.com/unity/whats-new/unity-3.4.html

8) Adding Game & Scene View Icons to GameObjects – Click on the GameObjects icon in the inspector. From this drop down you can select the icon type, color and even create a custom icon. You can also add icons to custom scripts. Select the script in the Project panel. Then click it’s icon in the inspector. This icon will get applied to all GameObjects that have this script attached. This is very handy for marking things like waypoints.
http://unity3d.com/support/documentation/Manual/Gizmo%20and%20Icon%20Visibility.html

9) Snap To Vertex or Collider – To snap to vertex, hold ‘V’ and then click and hold down on the desired vertex. Drag your mouse around to snap it to the required vertex of another mesh. To snap to collider, hold Shift while dragging in the center when using the Translate tool.
http://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.html

10) Scripting the Editor – This is one of my favourite features and something people do not do enough of. If there is something the Unity editor doesn’t do by default you can write it yourself. Extending the editor is very easy and incredibly powerful. As an example I wrote a tool called PlayModePersist that can save changes your made in the editor while in PlayMode.
http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html

If you have any additional items you would add please put them in the comments below.

Office Zombie Simulator on Kongregate

February 20, 2011 by Devin Reimer

I’m happy to announce the release of our new game Office Zombie Simulator. This game was created by Calin Reimer and myself for Kongregate’s Unity Game Contest.

While it is still a work-in-progress I am very happy with how it turned out considering how swamped I was this last month (So Many Rooms and client work).

When I heard the announcement for Kongregate’s Unity Game Contest I was very excited and knew I needed to create something for it. I love game development contests because they have a great feature; a fixed deadline.

The premise of “Office Zombie Simulator” is pretty simple, imagine a few zombie loving nerds are stuck in an office for the weekend. Instead of working they decide to setup the ultimate zombie apocalypse simulator.

The idea for “Office Zombie Simulator” came to me out of necessity.

One problem that we keep running into with developing 3D content is the amount of time and effort required to build all the necessary 3D models. So the idea was if we could reuse more models between projects we would save development time. Since another project we were working on required office equipment I thought if this game could be set in an office, we could hit two birds with one stone.

Other than that the game shouldn’t have any complex 3D models or animations (too time consuming) and needed to be easy to pick up and play.

After a few days of brainstorming, the concept for “Office Zombie Simulator” was born. It turned out to be a very cool concept and is more proof that creativity works best under constraints.

So give it a try, leave feedback and please rate.

http://www.kongregate.com/games/AlmostLogical/office-zombie-simulator

We are hoping enough people will enjoy the game to warrant us building a fully realized version. We have a lot of cool ideas that we would love to implement.

PlayModePersist – Unity Asset Store

January 11, 2011 by Devin Reimer

Have you ever wanted to make changes to a component in Unity while in Play mode and have them persist after you click stop? Have you ever accidentally made changes to a component while your game was playing and wish they could be saved?

After a lot of hard work I’m happy to announce ‘PlayModePersist’ is now available in the Unity Asset Store.

This Unity extension allows you to select which components on individual GameObjects you wish to persist and they will save automatically the moment you hit stop. No needed to copy and reapply your changes, no worrying about a “clipboard” being full. You are not limited to saving one component or one GameObject, you can persist as many component from as many GameObject as you would like.
Works with all component with script access including, Transform, Rigidbody, Physics Colliders and Joints, etc. Also supports custom built components. Complete list of supported components.

This feature is currently the #3 most requested editor feature and #10 most requested overall on feedback.unity3d.com.

Best of all it is easy to use, while in Play mode just click the ‘PlayModePersist’ dropdown below the Transform title in the inspector and click the checkboxes for the component you wish to persist. Once you click stop their current state will be persisted.

Please use the comment section below to let me know what you think. Also giving it a rating in the Unity Asset Store would be greatly appreciated.

Note: If you don’t know how to use/access the Unity Asset Store, simply open up Unity, click Window->Unity Asset Store. You can find this item under ‘Extensions’.

Update: New link to PlayModePersist: http://u3d.as/content/almost-logical-software/play-mode-persist/1tS

Special thanks goes out to Kevin Evans for his work that went into this extension.

Rigidbody Sleep Toggle – Unity Asset Store

January 6, 2011 by Devin Reimer

I’m happy to announce ‘Rigidbody Sleep Toggle’ is now available in the Unity Asset Store. What is ‘Rigidbody Sleep Toggle’ you ask? It’s an additional toggle (checkbox) called ‘Sleep On Awake’ that is placed at the bottom of the Rigidbody inspector. Clicking this checkbox automatically adds a custom component that makes that Rigidbody sleep at the start of the scene. This is sometimes very important to increase start up performance of your game. If your scene has lots of Rigidbodies they will all be in motion at the start of the game so preventing this can crucial.

While you could add a custom script yourself, this script not only saves time (just selecting/unselecting a checkbox), you can easily tell from within the Rigidbody component if it will be asleep at the start of the scene.

I have also added a menu option under ‘Edit’ that will allow you to in bulk make all Rigidbodies in your scene sleep on awake.

Now onto the best part, it’s now available in the Unity Asset Store for the low, low price of FREE.

Happy New Year Everyone! Please use the comment section below to let me know if you find it useful.

Note: If you don’t know how to use the Unity Asset Store, simply open up Unity, click Window->Unity Asset Store. You can find this item under ‘Extensions’.

Update: New link to Rigidbody Sleep Toggle: http://u3d.as/content/almost-logical-software/rigidbody-sleep-toggle/1tj.
Also I have now launched a new extension called PlayModePersist read about it here.

Unity3D Parachute – Cloth, Joints and Physics

November 2, 2010 by Devin Reimer

When I first received the Unity 3.0 Beta one of the first things I played around with was the new cloth physics. What better way to learn something than to make a tech demo. After some thought I decided on creating a parachute.

One thing I quickly discovered about the new cloth physics within Unity was that it is very heavy (requiring a lot of computing power). That means for the most part cloth physics are slow. So before you go off and try to create a game with lots of physics based cloths you have been warned, it will probably end up being too slow. While cloth does have its uses, they are a little more limited than I had hoped.

My original plan for this demo was to build a parachute using only cloth physics. I ended up having to tweak this a bit for performance reasons. Since in real life a parachute moving downward is fairly rigid so I instead opted to only swap in a physics based cloth once the parachute’s payload touches the ground. The rest of the time I would use a normal mesh renderer. This way I can get the parachute to collapse nicely over the payload but only use the physics aspect for a short period of time.

The parachute’s movement is completely driven by the physic system. A configurable joint is used to attach the Rigidbody of the parachute to the payload (in this case a crate). A physics force is then applied to the parachute based on the maximum amount of lift that parachute is capable of. This way if you increase the mass of the payload the parachute will fall faster and on the flip side a payload of less mass will fall slower.

I ended up leaving the Interactive Cloth’s options pretty much unchanged as changing some of them ended up impacting performance too much. The parachute’s cable are dynamically generated using LineRenderers.

This example is built is such a way that you should easily be able to attach whatever you would like as the parachute’s payload.

To check out the demo click here.

To get the source (unitypackage) click here.

Source Requirements: Unity 3.0

Thanks again to Calin for creating the models.

iTween Parameter Code Hinting

September 13, 2010 by Devin Reimer

For those who don’t already know, iTween is a great tweening library for Unity. If you haven’t yet had a chance to use it, go download it. I guarantee that you will find it useful.

Now that introductions are out of the way, on to the point at hand. Many code libraries (especially tweening libraries) have the problem that there is no access to code hinting for properties being passed into it’s functions. The reason being since there are so many possible parameters that could be past into each function a list of optional parameters are requested instead of a sequentially list of required parameters. This makes using these functions a lot easier and more customizable. The downside is there is no coding hinting for what  parameters could be possible passed in.

In the case of using iTween in C# you pass arguments into a Hashtable and that Hashtable is then in turn passed into the these functions.
Example:

Hashtable tweenHash = new Hashtable();
tweenHash.Add("x", -5);
tweenHash.Add("y", 5);
tweenHash.Add("time", 10);
iTween.MoveAdd(gameObject, tweenHash);

Or as a single line (if using Unity 3.0 or greater):

iTween.MoveAdd(gameObject,new Hashtable(){{"x",-5},{"y",5},{"time",10}});

Or an even shorter single line (does have additional creation overhead)

iTween.MoveAdd(gameObject,iTween.Hash("x",-5,"y",5,"time",10));

The only way to know what the list of possible parameters are for a particular function is to either a) open iTween’s source and look at the comments or b) look through the iTween documentation.

Since this slows down learning and speed of using a new library I set off to try to find a better way. After exploring some different options I think I have found a better way. I wrote an app that goes through the iTween library and creates a Helper class called iT (contained within iTweenHinting.cs). Using this class you will have the ability to access code hinting/discovery when using iTween.

For example:

Hashtable tweenHash = new Hashtable();
tweenHash.Add(iT.MoveAdd.x, -5);
tweenHash.Add(iT.MoveAdd.y, 5);
tweenHash.Add(iT.MoveAdd.time, 10);
iTween.MoveAdd(gameObject, tweenHash);

Or as a single line (if using Unity 3.0 or greater):

iTween.MoveAdd(gameObject,new Hashtable(){{iT.MoveAdd.x,-5},{iT.MoveAdd.y,5},{iT.MoveAdd.time,10}});

Or even shorter single line (does have additional creation overhead)

iTween.MoveAdd(gameObject,iTween.Hash(iT.MoveAdd.x,-5,iT.MoveAdd.y,5,iT.MoveAdd.time,10));

When you type ‘iT.’ within a code editor it will give you a list of all tweening functions within iTween. Once you select the function you wish to use (ex: MoveAdd), hit ‘.’ and your code editor will then give you a list of all possible parameters for that function (see image above).

The great thing about this method, is as you get more comfortable with the iTween you can write out the strings of the simple and easy to remember parameters, while still having the ability to fallback on the helper class.

To download iTweenHinting.cs click here (right-click save as).

Note: While I don’t expect the list of functions and parameters within iTween to change that often. I will do my best to keep iTweenHinting.cs up-to-date.

If you have any suggestions on ways I could improve/change iTweenHinting.cs please leave them in the comments below.

Interesting side note: For this project I wrote code that reads code to write code that allows you to write code faster. Plus it was AS3 that was reading and writing C#. Isn’t programming fun. :)