Unity Contribution Set Up Best Practices

This is taken from Unity Resource E-Book and some other online spaces, but outlines some general best practices for setting up a new Unity Project, particularly if you are going to be collaborating with others.

Organization

While there is no set folder structure, it is good to stick to some of the “common” principles, such as splitting up the project based on asset type (e.g. Art/Music/Code etc.). Here is a good example of one of the ways to organize your project.

Example of an unity Assets folder structure.
Example 1 for Organizing Project Hierarchy

Here are also some of the definitions you might come across for the different asset types:

First half of a table explaining Unity asset types.

Second half of a table explaining Unity asset types.

Workflow Optimization

When moving any files IT IS IMPERATIVE YOU MOVE IT IN UNITY ITSELF otherwise you will lose the .meta file that is associated with the object, and can cause significant problems for version control!

Unity generates a .meta file for every other file inside the project, and while it’s typically inadvisable to include auto-generated files in version control, the .meta file is a little different. Visible Meta Files mode should be turned on in the Version Control window (unless you’re using the built-in Plastic SCM or Perforce modes).

Aside from how and where you keep your assets inside the Assets folder, there are several design and development choices you can make to help speed up your workflow, especially when you’re using version control.

Prefabs

Use prefabs for everything. The only game objects in your scene that should not be prefabs should be folders. Even unique objects that are used only once should be prefabs. This makes it easier to make changes that don’t require the scene to change. (An additional benefit is that it makes building sprite atlases reliable when using EZGUI).

Use separate prefabs for specialisation; do not specialise instances. If you have two enemy types, and they only differ by their properties, make separate prefabs for the properties, and link them in. This makes it possible to

Scenes

myObject = FindMyObjectInScene(); if (myObject == null) { myObject = SpawnMyObject(); }


## Art

**Get the scale right from the beginning**. Make art so that they can all be imported at a scale factor of 1, and that their transforms can be scaled 1, 1, 1. Use a reference object (a Unity cube) to make scale comparisons easy. Choose a world to Unity units ratio suitable for your game, and stick to it.

**Make and use test art**

- Squares labelled for skyboxes.
- A grid.
- Various flat colours for shader testing: white, black, 50% grey, red, green, blue, magenta, yellow, cyan. Gradients for shader testing: black to white, red to green, red to blue, green to blue.
- Black and white checkerboard.
- Smooth and rugged normal maps.
- A lighting rig (as prefab) for quickly setting up test scenes.

## General Practice

![Table specifying C#/Unity naming convention.](./attachments/naming-convention.png)