Skip to main content

ScriptableObjects

From the Unity documentation:

ScriptableObject is a serializable Unity class that allows you to store large quantities of shared data independent from script instances. Use ScriptableObjects to centralise data in a way that can be conveniently accessed from scenes and assets within a project.

With that said, ScriptableObjects are a central part for data management in this asset and used in many areas, mainly for towers. As written above, they allow for manipulation of game data from within the project panel, without the need of opening a prefab separately - if the data would be stored in a script instance instead - and can be shared across different script instances without duplicating any data. Additionally, if you are using version control, ScriptableObjects are basically text files with plain values or references to other ScriptableObjects, which can be serialized very easily. This page describes what types of ScriptableObjects there are and where they are used in this asset.

All ScriptableObjects in this asset are located under TowerDefenseMultiplayer > ScriptableObjects.

Feature-ScriptableObjects010

ScriptableObjectExample AssetDescriptionUsed at
ClassDataScriptableObjectKnightsDefinition of a class and which towers can be used when playing that class.GameData component, Intro scene.
TowerDataScriptableObjectArrow_0Definition of tower values like range, damage and also reference data of next upgrade.On a tower prefab, in its Tower component.
NetworkPrefabsListNetworkPrefabsList of networked player prefabs spawned during the game. In this asset, only one (for the lobby).NetworkManagerCustom component, Intro scene.
NetworkPrefabsListTowerPrefabsList of networked tower prefabs spawned during the game. Base and upgrade towers go here.NetworkManagerCustom component, Intro scene.

For instructions on when to create these ScriptableObjects, e.g. for a new class or tower, please see the respective Guides.