In Unity 5
Good evening gents and ladies. This tutorial is about how to get models into the game. Secondly, how to color them so they look pretty.
Unity has the ability to handle a host of model types, though I tend to rely on the .fbx format for my imports. The Unity Asset Store seems to have struck that as their standard as well, so it works for me. Once you have your model file, you can drag it into the project view in a desired folder.
The model is imported and depending on what format you’re using, Unity may create a materials folder with the the model file as well. That makes the job much easier if you’ve packaged your materials with your model, but sometimes Unity messes things up. If you need to fix a material or otherwise set a new one, I’m going to show you the ins and outs of material editing in Unity.
Let me say first that this is probably one of the few things I’m not one hundred percent on board with the folks over at Unity. I can understand why they did it, but the process of assigning a texture to a model is a bit convoluted and it involves creating a material asset.
For the first step, we need to create a material asset, so go ahead and right click in your project view and go to Create > Material to create a material file.
If you click on your newly created material, it should open the inspector. Your material may look something like this one below, especially if you downloaded and installed the Standard Assets package from the Unity Asset Store. However, if it does not, that’s okay, because this is one of many Shaders that all function similarly.
A shader is a unique method of coloring a model using textures. They can make use of the same texture or group of textures most of the time, but different shaders will affect how the model appears in 3D space. From realistic to toon to translucent, almost all shaders contain a standard texture.
In the case of this shader, the main texture is labeled Albedo, though in others, It’ll just be called texture. Some shaders will have a normal map, which is a cool way to give your model the impression of having more polygons by affecting the way light bounces off of it. We won’t worry about Normal maps right now, and almost any shader should work without them.
You can add the main texture to your shader and it builds inside the material. If you ever want to change the textures in your material, there are two ways. You can either find the material asset and change it there through the inspector or you can access the material in your model’s inspector. See the screen below for an example of this. The material below shown at the very bottom of the inspector has an arrow to expand. Click that and you will usually see an option to change the texture.
An item of note…
- Unlike changing the image a 2D sprite uses, changing the texture used in a particular material will change the texture of any mesh using that material, so be careful when working with large projects with multiple models sharing the same material.
- It may be troublesome, but I recommend making new materials for each model you think may make use of a different shader or texture in the future.
And with that said, to add a material to your model, open up your model in the inspector and navigate to the mesh renderer component. You should usually find a material label. Drag over your material and the job is done. You should see the changes immediately.
But, that’s all I have for now. Join me again for the next tutorial!