@gamingislove

Hello.

Is there already a way to serialize other data types, which are serializable alongside with IBaseData?
I inherited class from SerializedBehaviour and it draws only the settings (IBaseData).
If do not inherit from it - only the serialized data is drawn.

How do I draw both data types?

I mean without creating custom editor for each component that usses makinom's IBaseData.


So far I made this thing.
It seems to draw both types and serialize them persistently.


public abstract class SerializedMonoBehaviour<T> : SerializedBehaviour<T> where T : IBaseData, new() { }

[CustomEditor(typeof (SerializedMonoBehaviour<>), true)]
public class SerializedBehaviourInspector : BaseInspector
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
this.ShowSettings(((SerializedBehaviour)this.target).SerializedSettings, false);
}
}



If this is normal and there is already no other way
Then you could add just one call to base inspector in order to fast fix this problem.


[CustomEditor(typeof (SerializedBehaviour), true)]
public class SerializedBehaviourInspector : BaseInspector
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
this.ShowSettings(((SerializedBehaviour) this.target).SerializedSettings, false);
}
}


But still.

It is not that great that we have to inherit from specific SerializedBehaviour in order to draw makinom's BaseData types..
This does not work with Visual scripting for example (the variable was not drawn in inspector for example GeneralConditionSetting) . And will not work with components which must be inherit from different class.

Can this problem be solved somehow?
Maybe with custom Attributes or by making BaseData [Serializable]?


  • You don't need to use the IBaseData handling in components at all, unless you want to make use of some of the ORK/Makinom specific selections (though for selecting the data assets, you can also just use Unity's standard asset selection field).
    Extending from SerializedBehaviour is also not needed at all. Many of the built-in components don't use it.

    ORK/Makinom use it due to Unity's data serializer not going deep enough, e.g. condition setup as they're available would not be possible with Unity's serializer.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • https://drive.google.com/file/d/1gg3FabSh2isB7_vt3MBlFyUQM5h1Zhpw/view?usp=sharing

    @gamingislove

    I was trying to use
    GeneralConditionSetting condition
    in my custom component.
    It was not drawn in inspector until I inhereted from SerializedBehaviour and transfered it into subclass and named the variable specifically - "settings".

    GeneralConditionSetting<GameObjectSelection> condition
    Am I able to use this data in my custom scripts without inhereting from SerializedBehaviour or writing my custom inspector?
  • TextusGames said: Am I able to use this data in my custom scripts without inhereting from SerializedBehaviour or writing my custom inspector?
    No, when not using SerializedBehaviour (which has the inspector automated for this), you need to write a custom inspector script if you want to use ORK/Makinom settings.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.