Skip to content

Clarification on Nested Built-In Types #1

Description

@twobitadder

hi!

just wanted to pop in and run into a question that may be a misunderstanding on my part.

i'm serializing some custom objects that contain an AtlasTexture in them that describe their appearance (typical inventory stuff). however, the serializer stumbles on the AtlasTexture, as it's not technically a script that i've registered (and indeed, has no script to speak of as it's just a built-in resource type).

while i can see the potential lack of safety in allowing something like a built-in type to be natively serialized, having some way of handling it - either in a default behavior that is very limited (a la EncodedObjectAsID in godot) or some documentation on workarounds - would be ideal i think. i realize i can override the base _serialize() function to describe an alternative way to serialize atlastextures, but i would prefer not to describe the serialization process for all of my objects for one native type 😅

some ideas that i think would be cool:

  • a sister function to _get_excluded_properties() like _get_exceptions() or something that allows you to map a property to a callable that describes how to serialize the property (otherwise keeping default behavior if the property is not listed in the exceptions list)
  • some kind of default "stub" behavior for native types like the EncodedObjectAsID example above
  • a suggestion in the docs to create a custom type that extends the built-in type and register that script (this is likely going to be my solution as i don't have many native types that must be serialized, but i can understand this being less scalable for large projects)

happy to talk about this at all if need be! it could be that i'm also missing some aspect of the serializer that i just did not dig deeply enough into.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions