GameObject - Unity
Game Object
Game object in unity is basically a container that requires properties to make them a character. Suppose a room the type of things you will place will be the type and use of the room. Likewise, components added to the game object will define the type of the game object.
Game objects have transform component attached to it that can't be removed.
GameObject.renderer
Game object renderer is use to make character appear on the screen. It can also be used to change the color of the object. Having further different properties.
To change the color of the Object
Taking a small example to learn, take a cube in the scene and add a script in the cube through add component. Then add the code given below.
void Update () {
if(Input.GetKeyDown(KeyCode.R))
{
gameObject.renderer.material.color=Color.red;
}
}
To make Object Transparent
Game object in unity is basically a container that requires properties to make them a character. Suppose a room the type of things you will place will be the type and use of the room. Likewise, components added to the game object will define the type of the game object.
Game objects have transform component attached to it that can't be removed.
GameObject.renderer
Game object renderer is use to make character appear on the screen. It can also be used to change the color of the object. Having further different properties.
To change the color of the Object
Taking a small example to learn, take a cube in the scene and add a script in the cube through add component. Then add the code given below.
void Update () {
if(Input.GetKeyDown(KeyCode.R))
{
gameObject.renderer.material.color=Color.red;
}
}
To make Object Transparent
GameObject g;
g.renderer.material.color.a = 0.5f;
g.renderer.material.color.a = 1.0f;
To make an Object visible and invisible
void example (){
renderer.enable=false;
}
void lightcom ()
{
if(Input.keybuttondown(keycode.space))
mylight.enable=true;
}
Comments
Post a Comment