We have been using Unity for quite some time now and although its a fantastic piece of software for developing games, there are a number things that can hinder your development time. This post hopes to remedy this and help everyone who uses Unity; from beginner to advanced.
If you want to add colliders, but are annoyed by the 0.01 import scale this is a handy little bit of code
public class FBXScaleFix : AssetPostprocessor
public void OnPreprocessModel()
ModelImporter modelImporter = (ModelImporter) assetImporter;
modelImporter.globalScale = 1;
modelImporter.addCollider = true;
modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Calculate;
- Use short names, and proper names. Call it what it is; a car would be Car.
- Choose names that are simple and can be spelt. Keep it simple
- Be consistent. This is for both naming convention and names.
- Do not use spaces, underscores, or hyphens if possible.
- Do not use abbreviations: InfantChild should NOT be infChild.
- Keep the most specific descriptor on the left: SelectButton, not SelectPaused. Its easier to find the word Select than searching the word button.
- At times when you have multiple items of the same name start at 0 not 1
- Use different words for different item types. Use Cup, Mug, Beaker instead of cup1, cup2 etc
- To find important items in the scene, use $ at the beginning of the name, so it always appear at the top of the scene hierarchy.
- It is good practice to name temporary objects with a double underscore __Bullet.
A god trick going around that maybe people have yet to hear is to use underscores between the core names. For example:
- Texture: Chair_Diffuse and Chair_NormalMap
- Skybox: TownSky_Top and TownSky_North
Other General Stuff
- Make sure function names are spelt correctly. They wont show an error.
- OnTriggerEnter and OnTriggerExit use COLLIDERS.
- OnCollisionEnter and OnCollisionExit use COLLIDERS.
- Put all pivots on the bottom of the prefab, this makes it easier to move around in the sceneview.
- On 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.
- Cameras in Unity can have their own skybox via adding the skybox component to any camera.
- 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.
- Use [ ] around important gameObject names or append an underscore to the beginning to place them at the top of the hierarchy.
- Holding down “Ctrl” you can drag an object block at a time (like a snap feature).
- Select the camera in the hierarchy then GameObject -> Align With View. This will put the game camera at the location of the scene view cam
- Select the main camera then GameObject -> Align view to selected to move the scene camera to the position of the main camera
- Create a material with the shader you want to use highlighted in the project browser it will use the selected shader by default.
- FBX Scale & Automatically add colliders 🙂
- Delete inspector array items (like the input manager) by clicking on the item and pressing cmd/control & delete
- You can insert into inspector array items by selecting an item and hitting cmd/control & d to duplicate it.
For further information and tricks, check out JasperStocker