[Closed] How can I convert a UObject to a derived type in a Factory Reimport?
I've made a new UObject type, UCustomMaterialInstanceConstant, that inherits from UMaterialInstanceConstant. I have also set up a UFactory and implemented the IReimportHandler interface to create these classes on import and reimports of a custom file extension. The system works until I need to import a new Custom material instance into a content browser location where a vanilla material instance lives. I'd like to have the (re)importer automatically convert the UMaterialInstanceConstant to my new class type. I have not been able to figure out how to do this. Currently, I"m attempting to do the conversion step with the following code.
I've attempted the conversion by:
Ultimately, none of these options have been successful because the calling function of UFactory::Reimport(UObject* Obj) always interacts with Obj afterwards. Deleting or mishandling the UObject in any way causes a fatal crash as soon as Reimport() finishes. What are my options here? Should I be approaching this from a different way?
The question has been closed Feb 07 '17 at 10:01 PM by AndrewHurley for the following reason:
The question is answered, right answer was accepted
Do I understand correctly you're trying to replace these classes in an existing asset? If so you should look at ActiveClassRedirects in DefaultEngine.ini (look for examples in BaseEngine.ini). This will allow you to replace classes when the asset is being loaded.
answered Feb 07 '17 at 09:57 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here