I am creating a digital boardgame, which consits of muliple boards, between which the gamepieces are moved by the players.
The script of the game board needs a 2D array of positions to know where to move a gamepiece when it recives one.
Currently to mark the positions on the game boards, I added placeholder gameobjects to the prefab and named them “spawnpointd”.In the
Awake() method I use
Transform.Find() to search for those gameobjects. Then, after I save their positions I call
Destroy() on them, so they do not show up in the game.
I see two problems:
- This is done for all Instantiated game board, altough the positions are the same on all of them.
- I read that using
Transform.Find()is heavily discourged by the experts in the community.
I wish to store the spawnpoint positions in a static array, so all instances refer to the same data. Furthermore I wish to easily modify these positions in the editor with visual help.
I tried serializing static members, but those do not show up in the editor to be able to modify.
(SerializeField) public static int TestNumber;
How to make static members visually changeable from the Unity editor?