Hey,
mmm⌠the template registration looks incorrect.
You should register the concrete type:
templates.Add(new TypeRegistryEntry
{
Type = "Unity.Collections.FixedList512Bytes<int>",
...
If you donât do that, the type cannot find a match. This is probably why is was not working (you may have changed this?)
It is great that you get the template working. This is always good to know how that thing work, in case you need to add any other custom type. +1000 Kodus!
However, while this work in your specific use case, I would suggest to override also the following regions (eventually just empty)
GHOST_WRITE
GHOST_READ
COMMAND_WRITE_PACKED
COMMAND_READ_PACKED
The reason being, the template you wrote only work for RPC: if this list is added to a command or a replicated component, then thing will break (because it wants to serialize a FixedString32).
I will use this occasion to talk a bit more about this use case (override template or adding template for new types).
This may be useful to anyone that would read this tread (just in case).
The template you written, CAN ONLY WORK FOR RPC and it is not overriding all the required fragments.
So, while it work for you, it is by no mean a âbest practiceâ to write a partial template for a type in this way.
When you make a template override that uses a base template (in this case the FixedString32) and you are changing the snapshot type you are using (in this case is a FixedList512 instead of FixedString32) you need to check how the base template implements the various fragments and overrides all the ones that are not compatible with the new type. In particular, for this one:
GHOST_WRITE
GHOST_READ
COMMAND_WRITE
COMMAND_READ
COMMAND_WRITE_PACKED
COMMAND_READ_PACKED
Also, in general, as soon as you register a type to code-gen, some assumptions are made:
1- it is supposed to work for type that are present in replicated component. The following regions must be present (even if empty):
GHOST_WRITE
GHOST_READ
GHOST_PREDICT
GHOST_COPY_TO_SNAPSHOT
GHOST_COPY_FROM_SNAPSHOT
GHOST_RESTORE_FROM_BACKUP
GHOST_CALCULATE_CHANGE_MASK
GHOST_CALCULATE_CHANGE_MASK_ZERO
GHOST_REPORT_PREDICTION_ERROR
GHOST_GET_PREDICTION_ERROR_NAME
2- if the template SupportCommand is true, the following regions must also be present:
COMMAND_WRITE
COMMAND_READ
COMMAND_WRITE_PACKED
COMMAND_READ_PACKED