SolidAlloy / GenericUnityObjects

Generic UnityEngine.Objects
Other
167 stars 13 forks source link

I'm using Odin serialization for scriptable objects - inheriting from SerializedScriptableObject. Can I use this package? #27

Closed dan-oak closed 2 years ago

dan-oak commented 2 years ago

I see in the readme that I'd need to inherit from your own classes. But I cannot since I need to inherit from my base clases. Do you support this use case or can suggest something else for me?

SolidAlloy commented 2 years ago

Hi, thanks for your interest in the plugin. I require inheriting from GenericScriptableObject because it contains an overridden CreateInstance() method that can take a generic type in to instantiate a generic scriptable object (which the default CreateInstance() method cannot do). Also, it simplifies the code in the plugin a bit, so it was convenient for me. But I didn't think of such a case where a ScriptableObject-derived type exists in a package or DLL, so you cannot change its inheritance.

I can certainly change this and not require inheriting from GenericScriptableObject, just like it works with MonoBehaviour right now. Thanks for pointing out the problem! I'll let you know when I implement it.

dan-oak commented 2 years ago

Thank you a lot! Will subscribe for updates. I was considering to use it, I actually did for some time, but found that serialization and GUI systems of Odin are more important for me. They add serialization to rest of the missing collections, and add easy way to extend inspector with convenient UI elements.

P.S. notes: It's actually a PITA of the OOP approach in general that's why component systems, for example, even exist. "Composition over inheritance". The problem not on your side actually, because inheritance is just happening to be one of the easy ways to solve problems like yours and like Odin's and I see why. I myself to use it often too. Some people, for example, can not use Odin, because they inherit from some other more important system for them. This is why it's often our job to compromise for something.

SolidAlloy commented 2 years ago

Hey, in case you are still waiting for this feature, I just released it as a part of the 2.16.0 version. Totally agree with you on the inheritance issue. If there is a way to resolve something without inheritance, it always comes out more versatile.