PlayerInfo _info = ScriptableObject.CreateInstance() Īfter running one of the above methods, you can access the scriptable object. It is useful when you want each instance to have a separate asset. This will help you build an asset in the code. Public class PlayerInfo : ScriptableObject Then refer it to the field defined in the player class. Use the create asset menu as below and create the asset. The only problem is that mostly everything in the shop is extremely expensive. There is a shop to customize your avatar and buy gear. Roblox is a basically a website, where you make games or play games. The first way is to create an asset through an attribute. Roblox is a game scripted in Lua, it's 3D, free (You can pay for virtual money), and has lots of tools. Observables - GitHub - Wolar-Games/unity-scriptable-object-variables: Simple implementation of variables in scriptable objects with optional integration. ![]() However, to do the above, you must have a scriptable object asset. ![]() Returns the same amount of Player Data in the field and is ineffective. After juggling ScriptableObjects for a few years, Ive found a better way by porting CastleDB, a structured static JSON database, to Unity. Unitys inability to fully separate game data from code is an issue that all developers eventually run into. Because player information can be stored in an independent class or in the player itself, or even struct. Beyond Scriptable Objects: Unity Data Management with CastleDB. ![]() So is this actually how you'd want to use scriptable objects or did I miss something? lolĪlthough the scribtable object is a very useful tool for storing information as an asset, it is not very useful for what you want to do. PlayerData.health = playerData.maxHealth Public void SetMaxHealth(BaseClass newClass) I originally just had a health script that handled all of it, but now it just references the scriptable object and adjusts the values in it public class HealthController : MonoBehaviourĬlassSelectButton.OnClassSelected += SetMaxHealth Here's my scriptable object public class PlayerInfo : ScriptableObject From my understanding, you want to try and limit the times you reference scripts since this causes things to become dependent, but with scriptable objects, it seems like you're supposed to reference them. I've been trying to learn more about scriptable objects because I've heard they're quite useful, however, I'm still a bit confused about how to work with them since it seems to conflict with the try to decouple your code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |