Hi guys,
How can I do to pass from “material1” to “material2” when I press a key?
I tried with this script, but this give me an error (the name “gameobject” does not exist in the current context)
Someone can help me? thank you!
using UnityEngine;
using System.Collections;
public class Luci4 : MonoBehaviour {
public Material material1;
public Material material2;
void Update () {
if (Input.GetKey(KeyCode.Alpha4))
gameobject.renderer.material = material2;
if (Input.GetKey(KeyCode.Alpha4))
gameobjet.renderer.material = material1;
}
}