I'm using a "toggle visibility" script on many objects in my scene, and in my gameControllergameController
class I'm storing references to them in an array like this:
public Fields[] fields;
then I access them by the array index:
fields[0].setVisibility(true);
This works fine, but this list is growing and everything is getting unmaintainable.
So I would like to iterate thru the references to the objects, find the script by it'sits game object name, and call the required function setVisibility(state)
.
A call, if possible should look like this:
GameObjectName.ScriptName.FunctionCall.State
In this way, I would have a clear overview of my code.
Is this possible in Unity C#?
Thanks!