I know this is a controversial topic being discussed a lot , but I have not found a clear answer yet.
So , there is a "Grid" in my game , which I implement it with an Array of GameObjects. This array should be accessed by different scripts in my game. My approach , is that I have a Game Manager , which is a Singleton , the array is public , and every script that needs to access it or make a change can do something like GameManager.Instance.GridArray[i,j]; .
Using singleton and public variables are heavily criticized for extensibility and coupling issues. What approach would be better for this situation ?
Class Nodethere is a functionneighborswhich finds the nodes neighbors , and in some other scripts I am using width and height that are defined in theGameManager\$\endgroup\$GameManager. It creates an array of nodes , the calculation of the path is generated in thePathfindingclass which needs no more info than start & end node since it usesNode.Neighbors()for each step. We only need the array in theNodeclass. I could just useGetComponentin myNodefor keeping a copy of the array but this wouldnt be much different. I dont want to make this array static. Generally , it works fine, but I would like to know if there is a better pattern. \$\endgroup\$