Unity Tips Tricks

So despite using Unity for some time I still discover little tricks or features in the editor that can make a developers life easier. Just today I stumbled across creating a GuiTexture whilst a 2D texture is selected not only applies the selected texture automatically but also sets up the pixel inset values!

So I figured there must be plenty of other little tips or tricks for the editor and thought i’d starta thread for others to add to it. Only 2 rules, firstly it must related to the editor, so no coding tricks or how to use a feature, secondly as a tip it should be quick and simple to do, nothing that requires many complex steps.

May I also request discussion is kept to a minimum, i.e no arguments over what is a tip and what might be common sense, e.g. camera’s can have individual skyboxes. I’d like, assuming there are more tips for this to be a useful resource. I may, time permitting compile all the suggestions into this first post.

Tips, Tricks Cool features.

001: Creating a GuiTexture whilst having a 2D texture selected in the ‘project pane’ will automatically use that texture (instead of the default Unity Logo) and correctly set up the pixel inset values.

002: Camera’s can have their own skybox via adding the skybox component to any camera.

003: Cubemaps are never compressed in vram (ARGB32) (standalone/web player), for skyboxes you are better off using 6 compressed textures if memory is an issue.

004: Use [ ] around important gameObject names or append an underscore to the beginning to place them at the top of the hierarchy.

005: Project Wide Defines - See here.

006: Holding down “Ctrl” you can drag a object one block at a time.

007: Have the scene camera in an awesome position and want to move the game camera to match?
-Select the camera in the hierarchy then GameObject → Align With View

008: Want to move the scene camera to the position of the main camera?
-Select the main camera then GameObject → Align view to selected

009: Create a material with the shader you want to use highlighted in the project browser it will use the selected shader by default.

010: FBX Scale Fix Automatically add colliders - See Silence post.

011: Delete inspector array items (like the input manager) by clicking on the item and pressing cmd-delete (or the Windows equivalent - think that is just delete).

012: You can insert into inspector array items by selecting an item and hitting cmd-d to duplicate.

013: FBX - select embed media when exporting your fbx files. The textures will then be placed into a seperate folder, which will be linked to your model automatically when imported into Unity.

2 Likes

I think this thread is a great idea :slight_smile:

A little trick I use is to put clauses around important gameobject names, this way they always show up at the top in the Hierarchy because of alphabetical sorting. That way It’s easier to find my important gameobjects when Im testing my game :stuck_out_tongue:

More of a programmer tip, a thread explaining how to set project wide #defines http://forum.unity3d.com/threads/71445-How-To-Set-Project-Wide-pragma-Directives-with-JavaScript?highlight=gmcs

Well, except that’s not true. Skyboxes are compressed, and they would never have worked on cards with low VRAM otherwise.

–Eric

Interesting I’ve always been partial to adding an underscore before a name to get it to the top of the hierarchy.

That’s what I said, cubemaps aren’t compressed. In standalone and webplayer they are ARGB32, so don’t use them for skyboxes, use the 6 textures method instead.

While holding down “Ctrl” you can drag a object one block at a time. It makes building levels much faster if you’ve made models to fit exactly that way.

I thought you were saying skyboxes aren’t compressed, but I see you’re talking about cubemaps specifically.

–Eric

Have the scene camera in an awesome position and want to move the game camera to match?
-Select the camera in the hierarchy then GameObject → Align With View

Want to move the scene camera to the position of the main camera?
-Select the main camera then GameObject → Align view to selected

If you create a material with the shader you want to use highlighted in the project browser it will use the selected shader by default.

Do you want some extra editor functionality you think would be really awesome? Learn the editor scripting API’s… you can do so so much with them!

Annoyed by the 0.01 import scale factor? Want to automatically add colliders?
Well…now you can.

using UnityEditor;

public class FBXScaleFix : AssetPostprocessor
{
    public void OnPreprocessModel()
    {
        ModelImporter modelImporter = (ModelImporter) assetImporter;                    
        modelImporter.globalScale = 1;        
		modelImporter.addCollider = true;
		modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Calculate;

    }   
}

Some great tips, keep em coming.

Really could have done with the scene/game camera alignment tip a few days ago :wink:

Always like tip threads.

Here’s mine - you can delete inspector visible array items (like the input manager) by clicking on the item and pressing cmd-delete (or the Windows equivalent). You can also insert by selecting an item and hitting cmd-d to duplicate.

I went an embarrassingly long time before realizing this.

When I first started importing FXB models, they would import without their textures.

Importing the image files before the fxb file solved this problem.

Even better than this, if you select embed media , you’ll export your fbx files, with their texture, into unity, in a seperate folder, which will be linked back up to your model automatically.

Thanks,

Have added the additional tips to the OP.

Any more?

I’ve created a video series dedicated to this topic. There are very short (2-7 minutes) and focused on a specific topic. Enhttp://www.youtube.com/user/unitytipsandtricks/videos

Insominx - I’m using the Movie Textures right now, and your procedural geometry one was a lifesaver on my last project (in sig). Thanks for making the solutions to real problems, real simple to follow.

Gigi.

Great video’s and tutorials but generally those aren’t really the tips tricks I refer to here.

Tips Tricks in this thread are for lesser known features, shortcuts and abilities of Unity that most developers will never stumble upon, they may not even be in the documentation at all.

However your colour picker video is a perfect example of the sort of thing that would have gone into this thread. It took a while for myself to realise you could click the ink dropper and access anything on screen.

Ok, this one is a productivity thing. When developing for mobile, keep the screen-size in standalone. Change the standalone size via a editor extensions script. i.e I have a “iPhone 3GS” button that changes the screen size and aspect ratio to that device. Same with iPhone 4 and iPhone 5… Particularly useful when using NGUI. Obviously use a landscape check-box to switch between landscape and portrait. Use aspect ratios or extend with other device pixel sizes.

Edit: There should be a picture here :frowning:

1253807--54472--$guiios.jpg

Can you explain? I’ve no idea what you’re talking about.
Gigi

At a random guess they may have been referring to using a script like this from the docs.

I never realised you can set the defaultScreenWidth/Height for both standalone and web from scripts. It even works to change them in Awake() from a script. This is pretty useful for the cases Justin points out, but also for me where I have projects which contain lots of little projects and frequently require a specific screen size. Used to be i’d have to keep going into edit>player settings>player to change them, but using these functions in a script seems to be a perfect solution.

Of course you’ll have to be careful of script order and any other scripts which require using screen width/hieght to ensure its changed before they run.

e.g.

	public	int		_screenWidth;
	public	int		_screenHeight;

	void Awake ()
	{	
		PlayerSettings.defaultScreenWidth =  _screenWidth;
        PlayerSettings.defaultScreenHeight = _screenHeight;		
	}