Extending the PCGComponent

Hello, I have a use case for extending UPCGComponent, but it seems like this is intentionally prevented by making the constructor private (and UHT needs to implement a default constructor).

I am wondering if there is a specific reason this is prevented, or if it should be ok to make the changes to allow extending the component.

The need for this is that by default the PCGComponent does not call Release on the ManagedResources objects when the component is destroyed. We are using PCG graphs to place certain interactable actors, so the spawn mode cannot be merged. This means that when you delete the PCG actor that generated the actors, the actors are not cleaned up, which complicates the workflow.

I also do not want to add the resource cleanup to the base class, because we do not need this behaviour on all our uses of the PCG Component. So overriding OnComponentDestroyed is ideal.

Please let me know if you think extending PCGComponent is an alright approach, or if there is a better solution to clean up loose generated actors when the component is destroyed.

Thanks!

[Attachment Removed]

Hi Thomas,

It might work, but we certainly have some non-exposed code in the component because some parts of it need to be public for editor reasons rather than it really being part of the public API, so if you try it you might need to expose additional functions.

The PCG Component isn’t really designed to be extensible per se , especially as we move to a less-component centric management of PCG in 5.8 and beyond.

However, don’t let that stop you from trying. I don’t see any major hurdles or issues with your suggested change on your end.

Hope this helps,

Julien

[Attachment Removed]

I noticed the following warnings during cook, so I have decided to integrate this change into the base class with a flag to enable it. This works for our use case.

Init LogProperty: Warning: Serialized Class /Script/PCG.PCGComponent for a property of Class /Script/<Custom PCGComponent type>. Reference will be nulled.

Thanks

[Attachment Removed]