Skip to content

Commit

Permalink
Remove redundant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTwentyThree committed Feb 19, 2024
1 parent 91bcbac commit b56f030
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions Example mod/SerializableBehaviourExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<StopwatchSignExample>();
stopwatchSignExampleSerializeMethodInfo = stopwatchSignMethodInfos.Item1;
stopwatchSignExampleDeserializeMethodInfo = stopwatchSignMethodInfos.Item2;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit b56f030

Please sign in to comment.