Ref Serializer's icon

Ref Serializer 1.1 Scripts 4.2 Community

Submitted by user KoBeWi; MIT; 2024-08-01

Utility class for registering and serializing light-weight RefCounted-based structs. It can be used as a replacement for Resources; it comes with its advantages and limitations.

Register a type with:
RefSerializer.register_type(&"ClassName", YourClass.new)
Where ClassName is the name used to create and serialize the type and YourClass.new is a constructor Callable, which will be used to create instances of your class. YourClass can be any class, including custom internal classes. It needs to extend RefCounted.

Create instances with:
RefSerializer.create_object(&"ClassName")
It returns an instance of your class created with the provided constructor method.

Serialize with:
RefSerializer.serialize_object(some_object)
where some_object is an instance created with create_object() or deserialized using deserialize_object(). The methods returns a Dictionary that represents your object.

Or use store methods:
RefSerializer.save_as_text(some_object, "res://object.txt")
RefSerializer.save_as_binary(some_object, "res://object.not_txt")

Check the repository README for more details.


View files Download Submit an issue Recent Edits