Hi
I am not a programmer and know little about scripting:
What I am trying to do is to switch material on a game object after clicking on another game object (both objects are 3 objects).
2 game objects in the scene. 1 is functioning as a power button that switches the material on the other game object (simple plane with 2 different materials)
This is what I have so far. It works only when I click on the actual object with the 2 materials and not when clicking on my switch game object
using UnityEngine;
using System.Collections;
public class SwitchMaterial : MonoBehaviour
{
public GameObject Screen;
public Material[ ] materials;
int index = 0;
void Start()
{
renderer.material = materials[index];
}
void OnMouseDown()
{
index++;
if(index >= materials.Length)
index = 0;
renderer.material = materials[index];
}
}
Any help would be apreciated
Thanks