Help with creating a camera center of active object script

I have an array list that cycle their enabled state using this code:

public GameObject[ ] gameObjectList;
private int index = 0;
public GameObject buttonGameOjectSwitch;
// Start is called before the first frame update
void Start()
{
foreach (GameObject go in gameObjectList)
{
for (int i = 0; i < gameObjectList.Length; i++)
{
gameObjectList*.SetActive(false);*
}
}
}
public void enableGameObject()
{
if (buttonGameOjectSwitch)
{
gameObjectList[index].SetActive(false);
index = (index + 1) % gameObjectList.Length;
gameObjectList[index].SetActive(true);
}
}
the list being UI button elements that are clickable. could someone help me with a script that would make the camera centre or lookat the active element so the camera always pans to the active element with it centred… Any help will highly appreciated still a serious newbie at coding so please bare with me…

Use code tags, as mentioned in the first sticky post on the forum.

You can probably use:

Camera.main.LookAt(gameObjectList[index].transform.position);

Thanks StarManta… Let me try that, will let you know how it goes…

This is the error message am getting now. Any ideas what i can do? The script is attached to an empty gameobject am calling Point Of Interest Manager if that helps

Oh, sorry, that should have been …main.transform.LookAt…

thanks for the prompt response… let me try that…

thanks a million StarManta… that works, thanks again for the help…