They are, in fact, serializable, custom data structures. In essence, a Scriptable Object is an instance of a script in your project, separate from MonoBehaviour, that allows you to store large amounts of shared data independent from class instances. I've tried regenerating my units in the Visual Scripting project settings, and 'Item' is added as a type in the list of node types.Įverything works fine in the Unity editor. Scriptable Objects are a special kind of data container that Unity provides us with. My scriptable objects are located in the Assets/Resources/Items folder This script is located in my Assets/Scripts/ScriptableObjects folder. Here's the code from my script that defines the SO: Scriptable Tag is an empty Scriptable Object, that is, its a Scriptable Object with no logic and no fields, it exists only to create unique Scriptable Objects. Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. So far I have something that works: // changes PartyMember Lalala. You can name the object whatever you wish. But if I drag - drop the SO into the inspector, its always null. I found out that if I use Resources.Load, no problem occurs. I can see that its referenced in the field in the inspector, but its still null in debug. Figure 10: Creating a new Player Unit, a Scriptable Object. I tried debugging, and in line 35 of the StatContainer class, the statData itself is null. In the Assets window, under the Scriptable Objects folder, right-click and navigate to Create -> Character Creation -> Player Units as shown in Figure 10. I've created a brand new test scene that only contains a prefab which has a list variable containing 3 scriptable objects (located in my project Resources folder) and a script graph containing my flow which logs a count of the list to the debug log, and prints the description of the first scriptable object in the list.Įverything works fine when I test in the Unity editor, but when I build for iOS and run it on my phone, the scriptable objects data never gets loaded (in this case, the description.) You can see in the mobile console that there's an error for a missing arg which is where the description is connected. I was wondering what the 'correct' way to save scriptable objects in Unity that are changed during Play mode. To use Scriptable Objects, you must first create them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |