So i was thinking maybe in edit mode you are not required to set dirty at all within the OnEnable function? Maybe that is why SetDirty is marked as obsolete? Or is it just obsolete by means of keeping editor code out of runtime assemblies? Any clarification why its marked as obsolete would be great. One of the main use cases for ScriptableObjects is to reduce your Project’s memory usage by avoiding copies of values. Perhaps with reflection i could manage a way to call EditorUtility.SetDirty but i feel like that would be a little bit of nonsense. A ScriptableObject is a data container that you can use to save large amounts of data, independent of class instances. I check and copy into MonoBehaviour, GameInput.IGameplayActions and attach. Input System in ScriptableObject not working for me. In Editor works fine, but when i build then I ran into a problem. And i was interesed about ScriptableObject & InputSystem. The problem is to set dirty i use the obsolete SetDirty() member method inside ScriptableObject when any changes occur i handle them, modify any serialized fields and would like the changes to be saved. I'm keep an eye on this project out of curiosity. ![]() This works good because OnEnable is called for all scriptable objects in the Assets folder. However, it may add some complexity to the code, and care must be taken to ensure that all IUpdateable objects are added and removed correctly from the UpdateV2 list.Hi there, I've got a scriptable object class where in the OnEnable message when Application.isEditor is true i do some type checking against previously stored serialized data. Create a monobehaviour with a reference to the list in point 2 that calls those functions when their callbacks are called. Overall, this approach provides a flexible way to organize update functions in Unity, and can help reduce code duplication and improve maintenance. Create a scriptable object with a list that references the scriptable objects I want to receibe normal monobehaviours callbacks, I called it MonoCallBacks. The UpdateableMonoBehaviour class overrides the update methods for each update type, allowing derived classes to implement specific behavior for each one. The UpdateV2 scriptable object has methods to add or remove IUpdateable objects to the appropriate lists, depending on their UpdateMask, and properties to store the interval for each update type. UpdateableMonoBehaviour subscribes and unsubscribes itself to a ScriptableObject called UpdateV2, which stores a list of IUpdateable objects, organized by update type (update, fixed update, or late update). For example, it has: Awake, OnDestroy, OnDisable, and OnEnable. Then, an abstract class UpdateableMonoBehaviour is created, which inherits from MonoBehaviour and implements IUpdateable. CreateAssetMenu(fileName 'Foo', menuName 'Scriptable Objects/Foo', order 1) If you’ve looked at the Scriptable Object documentation, you may have noticed that it has a few methods similar in name to those on a MonoBehaviour. The idea is to define an interface IUpdateable with methods for update, fixed update, and late update, and a property UpdateMask that indicates which of these methods should be implemented. We can still define fields and methods, or use some of Unity’s callbacks: Awake(), OnDestroy(), OnEnable() and OnDisable(). ![]() From a technical perspective, ScriptableObjects, like MonoBehaviours, inherit from UnityEngine.Object. This is an interesting approach for centralizing update functions in Unity, which can help reduce code duplication and simplify maintenance. They are very useful to store configuration data for your game and your objects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |