How to setActive to change the material

I tried to gaze spheres to change a 3D plane materials as change GUI pages by use event trigger and bool enabled but when i point back to the first sphere it doesn’t change anything. How to write a script to setActivate ??

https://youtu.be/8OoHxHIOL90<<<<<<<<<<<<< video


if i point a sphere,the scripts will activate.

{

public Material page_1;

void Start()
{
    
}

void Update()
{
    GetComponent<Renderer>().material = page_1;
}

}

To change a renderer material, you need to create a new material array and update the materials array (not material which is just a handy acessor to change active material attributes). Here is some example code:

void SetMaterial()
{
    var newMaterials = new Material[1];

    newMaterials[0] = myMaterial;
    GetComponent<Renderer>().materials = newMaterials;
}

thank you