![]() ![]() This will let you set the values in the editor without giving access to the variable from other scripts.Įach sword will need it’s own unique implementation of the SwordData ScriptableObject. In Unity, the SerializeField attribute allows you to have private script variables that are exposed in the Inspector. attackDamage: An int to hold the attack damage of the sword.goldCost: An int to hold the gold cost of the sword.icon: A sprite to hold the icon of the sword. ![]() description: A string to hold the description of the sword.swordName: A string to hold the name of the sword.Instead, it will be treated like any other common asset that can be created, similar to creating a prefab, scene or material.įill this script with some serialized fields that will contain all the data, corresponding with the information displayed on the Sword Merchant UI. This action tells Unity that you still want to use Unity features and methods, like a typical MonoBehaviour, but you’ll no longer need to put this script onto a GameObject. Public class SwordData : ScriptableObject Inside this class, start by deriving from ScriptableObject instead of MonoBehaviour: This class will be used as a container for all the sword data that will display in your Sword Merchant shop. Under the Scripts folder, create a new script called SwordData. It’s time to make your first ScriptableObject! Sword Prefabs: Contains a prefab of every sword in the Sword Merchant scene.įirst, make sure you are in the Sword Merchant scene.Sword Icons: Contains thumbnails of each individual sword. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |