Switching material

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

this script will need to be attached to the switch and the gameobject you want to change materials on should set in the code or dragged from the hierarchy into the script variable.

If I apply the script on both of the objects, both objects’ material will be switching

Indeed, you dont have the script on the object you want to change, just on the swith and assign the object to change in the inspector

Then this;
renderer.material

should be

Screen.renderer.material

Super!!!
Thanks works like a charm:)