Unity 3D Tips

Some more Unity 3D tricks and tips for you nice folk.


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

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.