sinbad / SPUD

Steve's Persistent Unreal Data library
MIT License
308 stars 45 forks source link

SaveGame UPROPERTY on type TSubclassOf is treated incorrectly #14

Closed rfsheffer closed 2 years ago

rfsheffer commented 2 years ago

Currently the system does not support TSubClassOf for saving, but if somebody sets a TSubClassOf as a savable property it treats it like a non-actor UObject. The save/restore process acts like it saved the property correctly tho what is saved is just a class identification (tho incorrect) and nothing is restored on load. It should throw the general "unsupported type" error instead.

Cheers and thanks for the great plugin :) Ryan

rfsheffer commented 2 years ago

I need TSubClassOf saved in my own stuff and the way I differentiate the field is to simply change the CastField to ExactCastField in TryWriteUObjectPropertyData and TryReadUObjectPropertyData.

sinbad commented 2 years ago

So presumably on restore you instantiate the referenced object yourself? SPUD won't be able to really - even if we derived the concrete runtime type, it could be from somewhere we don't have access to like your own code or a plugin.

rfsheffer commented 2 years ago

As long as the type is loaded as in the module has been linked the class reference can be made. Wheather it be a blueprint dynamic class or native. I cannot see any reason for TSubClassOf to not be serializable and restored to the property. I am doing it in custom code however. Anyway, this issue is just to mention TSubClassOf is false possitively saved and restored.

sinbad commented 2 years ago

OK, I've added official support for TSubclassOf properties.