diff --git a/Example mod/SerializableBehaviourExample.cs b/Example mod/SerializableBehaviourExample.cs index c74c2ef05..f26d25176 100644 --- a/Example mod/SerializableBehaviourExample.cs +++ b/Example mod/SerializableBehaviourExample.cs @@ -26,7 +26,7 @@ private void Awake() realtimeCounterSerializeMethodInfo = realtimeCounterMethodInfos.Item1; realtimeCounterDeserializeMethodInfo = realtimeCounterMethodInfos.Item2; - // Do it for the stopwatch + // Do it for the stopwatch class too var stopwatchSignMethodInfos = ProtobufSerializerHandler.GenerateSerializeAndDeserializeMethods(); stopwatchSignExampleSerializeMethodInfo = stopwatchSignMethodInfos.Item1; stopwatchSignExampleDeserializeMethodInfo = stopwatchSignMethodInfos.Item2; @@ -146,42 +146,25 @@ private void Update() timePassed += Time.deltaTime; } - // Below are two listeners from the optional interface IProtoEventListener: - // OnProtoDeserialize happens after this MonoBehaviour's GameObject full hierarchy is deserialized public void OnProtoDeserialize(ProtobufSerializer serializer) { deserializations++; } - // OnProtoSerialize happens before this MonoBehaviour's GameObject full hierarchy is serialized public void OnProtoSerialize(ProtobufSerializer serializer) { version = 1; serializations++; } - - // Below are the required static methods for Protobuf serializer to serialize and deserialize this MonoBehaviour - // You can find more examples in ProtobufSerializerPrecompiled just like Serialize11492366 and Deserialize11492366 - // Serialize must be a "static void" with parameters (YourType, int, ProtoWriter) + public static void Serialize(StopwatchSignExample stopwatchSignExample, int objTypeId, ProtoWriter writer) { - // If you only have basic types you only need to use the generated methods but you may need to adapt this with more complex types - // In that situation, please pick the right WireType for your variables and adapt the following Write[Object] call - - // In this case, we only have basic types to serialize so we just invoke the generated method SerializableBehaviourExample.stopwatchSignExampleSerializeMethodInfo.Invoke(stopwatchSignExample, objTypeId, writer); } - // Deserialize must be a "static YourType" with parameters (YourType, ProtoReader) public static StopwatchSignExample Deserialize(StopwatchSignExample stopwatchSignExample, ProtoReader reader) { - // Here you need to use the methods Read[Object] accordingly to what you wrote in Serialize: Write[Object] - // Also the different cases must be using the same field numbers as defined in Serialize - - // In this case, we only have basic types to serialize so we just invoke the generated method stopwatchSignExample = SerializableBehaviourExample.stopwatchSignExampleDeserializeMethodInfo.Invoke(stopwatchSignExample, reader); - - // Return the same object you've been modifying return stopwatchSignExample; } } \ No newline at end of file