Custom Serializer Improvements - Mainly for Scriptable Objects #508
Closed
Katerlad
started this conversation in
Feature Request
Replies: 1 comment
-
This is possible with the new serializer tech but won't be available until that's released of course. https://trello.com/c/i0rAIpSm/25-serializers-read-into-reference |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The main goal with this suggestion is to have the option to serialize Scriptable Objects over the network by just an ID.
I say option so people have the ability to choose if they want to implement static immutable scriptable objects ( The largest Use cases)
or the rarer use case which is using Instances of scriptable objects and trying to serialize the whole thing.
Currently only the smaller use case is supported natively.
The Problem
Almost all over the discord server, you see time and time again, people making their own ways to serialize static scriptable objects. Scriptable objects are used for Items. abilities and effects in many games and people love to attach the sprites associated to these abilities or items, and other fields that are not serializable.
Most people come up with their custom solution, usually along the lines of making a subclass of scriptable object with a GUID value, and using the ID to sync across the network. Usually on the OnChange event, take the changed ID and convert it to a normal scriptable object that you store separate copies of on the server and client so you can see the scriptable object in the inspector as well as use the scriptable object in your code, instead of the ID.
Potential Solutions
Interface Solution
Create a interface like ICustomSerializer or ISerializerOverride that allows a class to override the automatic serializer process, even for subclasses/derived classes. Somehow tying the serializer system to check if the type being serialized is ICustomSerializer, and use its logic instead.
Ship Fishnet With A Abstract NetworkScriptableObject Class
Not the most extendable, but if Interface method was not possible, maybe ship fishnet with a new class called NetworkScriptableObject
A SerializeField Bool to toggle Scriptable Object Lookup vs Serializing the whole sciptable object.
A Virtual Method to override the Lookup behaviour.
Conclusion
If the potential solutions sound dumb, that's cool too. The point is some solution that will allow built in support of sending scriptable objects and their subclasses by ID simply and Easily. So that we can just pass around scriptable objects, and not their ID.
If This is Already Possible
I apologize if this is already possible and its just a bug, or misunderstanding of how the custom serializers work. I don't mean to clutter the suggestions. If its possible and not a bug, we can get this process up as a Guide in the docs so that people can implement it more easily. Like myself if im not understanding :)
Beta Was this translation helpful? Give feedback.
All reactions