It’s time to create the first gameObject!
To start, click GameObject menu, 3D objects, and we can choose from primitive object , like cube, sphere, cylinder, etc.
For now, create a cube
Really simple right?
But as you notice, it appear too far from my view, because its position is random in the scene.
To reset its position, highlight the cube, in the inspector posision the mouse over the word transform, right click and reset.
Reset is a fastest way to reset position to 0, 0, 0.
If you need some specific position, always in the inspector you can write directly the position that you want.
This work with every voice in the inspector : Position, Rotation and Scale.
When you have an object in scene, if you highlight the camera in the hierarchy, you see that cube in the preview.
Every change you make at the cube in the scene, change the preview. For example, if I move the cube and rotate, this is what happen.
Now, talk about materials. If you look at inspector with cube highlighted, you see the components of that object.
Transform is the only component that every gameObject have.
As you can see, the cube has the transform,
the mesh filter, which define the geometry for the gameObject,
has a mesh renderer which define the visual rapresentation of that object.
If you toogle on and off the mesh renderer component
you see object appear and disappear from scene, is active in the hierarchy but not visible.
This because mesh renderer allows the camera to draw that object.
Always in the mesh renderer window we have materials.
If you click, see the actual material, in this case i default material, and always here you can change the color.
You also have the Box Collider componet, which make the object interactible with physics collision.
To begin, and for keep clean your project, create a folder material.
In the project menu, over asset, right click, create, folder and name it Materials.
Inside the folder, right click, create, Material.
After create it, name it Cube_mat.
In the Cube_mat inspector, you can change the color throught albedo channel.
If you click, it open a window with color wheel
Drag the little round cursor or click directly in the color wheel to change it.
You can also write directly the three variant in number of red, blue and green.
A stands for alpha, where 0 means completely transparent.
Choose the color you like.
After that, you can set the color of cube with some methods.
Hold left click on material and you can drag it directly to the cube in the scene,
or to the cube in the hierarchy.
With the first method you see instant change, with second no, but if you release, the cube change color.
You can also go to the Cube inspector, and drag the material in the mesh renderer component, material, element 0.
Also in this case, to see change you have to release the left button.
This is how we change objects’ color in the Scene.