Unity 3D Tips – Updated August 2016

This is an updated version of my last Unity 3D Tips post, some new tips and gotchas added to the list.

Autosave Script

See the previous post here. A must have script to auto save your scene when you press that play button. If you forget to save and Unity hangs or you have an infinite loop in your code somewhere you’ll lose any editor scene edits you made.


Inspector Lock

Ever noticed that tiny tiny lock icon in the top right corner of the inspector window? Me neither until someone pointed it out to me the other day! It’s for locking the inspector window to the view of the GameObject (or whatever else) you have selected at the time. You know when you want to drag some prefab into the inspector window and you accidentally click the prefab and it opens in the Inspector instead? Well just click the lock icon and it won’t change.

Unity - Lock the Inspector View
Lock the Inspector View with the little Lock Icon

iPhone 6+ Black Screen Gotcha

Be sure to test on an iPhone 6+ (plus – the large one). For some reason the game view scene in my Snaky Squares turns black after the scene is re-loaded, just on iPhone 6+, and I spent most of a day debugging to find the problem before ending up on a Vuforia form (here).  The “fix” for me, as with Vuforia, was to change the default graphics API; “Player settings” -> “Other settings”, un-checking Auto Graphic API and moving the “OpenGLES2” option to the top (over metal). Sure enough it fixed the black screen problem in Snaky Squares with iPhone 6+.

Did You Edit Scene Objects Whilst in Play Mode?

Everyone tells you when you edit scene objects in play mode they are lost when you stop the play – it’s a lie! Well partly, a true lie but there is a way you can save those edits!

  1. Still in play mode, click and highlight the game object in the hierarchy that you changed.
  2. Hit CTRL+C to copy the game object (Command+C on Mac).
  3. Stop playing the scene (CTRL+P or click the play button to stop).
  4. Hit CTRL+V (Command+V) to paste the object in the hierarchy window.
  5. You now have another copy of that game object, which also has the edits you had made in play mode. Delete the old object. Yes this copies all its children too.

Single Step One Frame at a Time

  1. Hit the pause button, or use Debug.Break(); in your code to pause,  OR use CTRL+SHIFT+P keyboard shortcut to pause at any time (Command+SHIFT+P on Mac).
  2. Step through using the CTRL+ALT+P keyboard shortcut (Command+ALT+P on Mac).

Great for debugging timings, animations and lots more.



Editor Settings

When you are running your game, any changes you make to objects in the inspector are temporary and are lost when you stop running. You WILL find you forget you’re running once in a while and lose your changes! To help stop this you can change the color of the Unity editor when running: Find the option in the menu Edit->Preferences, select Colors and then change the “Playmode Tint” to a nice RED or similar.

Unity 3D Tips - Playmode Tint
Unity 3D Tips – Set your “Playmode Tint”

Android Keystore Keys

If you are targeting Android and you are using your keystore file you need to input those pesky passwords every time you start Unity. Most annoyingly if you forget to enter them Unity stops after it builds the APK to tell you they aren’t there!!! And then there are the times Unity crashes or you need to close and reopen the editor, then forget to put the keys in again and it trips you yet again! Arrrrgh!

There is a solution! It does mean you have your Keystore keys in a script so decide for yourself if you’re happy about that security issue. Here is the code for the script, copy it into a new script file in your “Assets/Editor” folder (name it what you like). Fill in the passwords inside the quotes for keystorePass, keyaliasName and keyaliasPass.

using UnityEngine; 
using UnityEditor; 
using System.IO;

public class PreloadSigningAlias
    static PreloadSigningAlias()
        // Fill these three in
        PlayerSettings.Android.keystorePass = "";       // Keystore password
        PlayerSettings.Android.keyaliasName = "";       // Key alias name (the one you select in the drop down box)
        PlayerSettings.Android.keyaliasPass = "";       // Key password