GymnasiumOnDemandPrefabSpawner
A class in Root.Township, ATT.FeatureTestGymnasium.
Board of buttons in the feature test gymnasium, one per configured prefab plus Destroy All. Server spawns the prefabs in a spawn area; the button layout syncs to clients.
- Listed in ATT, Features and other game namespaces
- Inherits or implements
NetworkEntityBehaviour,ISavable<GymnasiumOnDemandPrefabSpawnerData>,ISavableSave<GymnasiumOnDemandPrefabSpawnerData>,ISavableSaveBase - Derived types
GymnasiumOnDemandPrefabSpawnerData
Constructors
| Member | What it is |
|---|---|
GymnasiumOnDemandPrefabSpawner() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private Vector3 backgroundSize | Size of the board background, used for the button layout. |
private Transform board | Transform the buttons are placed on. |
private LabelledButtonWrapper buttonPrefab | Labelled button prefab. |
private Vector3 buttonPrefabSize | Size of one button, used for the layout. |
private uint[] prefabsToSpawn | Network prefab hashes to make buttons for. |
private SpawnArea spawnArea | Area spawned prefabs are placed in. |
private readonly List<NetworkEntity> spawnedNetworkPrefabs | Entities this board has spawned, for Destroy All. |
private MethodSync syncButtonSetup | Sync for the button setup. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the button setup sync. |
void Load(GymnasiumOnDemandPrefabSpawnerData data, ISerializeChildren childSerializer) | Loads the prefab list and board position from save, and builds the buttons. |
override void OnConnected(Player player) | Sends the button setup to the new player. |
GymnasiumOnDemandPrefabSpawnerData Save(ISerializeChildren childSerializer) | Saves the board position and prefab list. |
6 private and internal methods
| Member | What it is |
|---|---|
private LabelledButtonWrapper CreateButton(Vector3 position, float scale) | Instantiates a button on the board at a position and scale. |
private void DestroyNetworkPrefabs() | Server: destroys everything this board has spawned. |
private void SetupButton(LabelledButtonWrapper button, Action action, string label) | Server: hooks the button's action. Client: sets its label. |
private void SetupSpawnButtons() | Lays out one button per prefab, named after it, plus a Destroy All button. |
private void SpawnNetworkPrefabWithId(uint networkPrefabId) | Spawns the prefab at a random point in the spawn area and tracks it. |
private void SyncButtonSetup(IPlayer player, Stream stream) | Sends the prefab list and board position; clients rebuild the buttons from it. |