Hello. Every time I play my game it’s running normally. I can open the UI inventory but after leaving it for quite some time and open the inventory again It crashes with “EXCEPTION_ACCESS_VIOLATION reading address 0x02000fa0”. I keep a reference in my player controller, I create the widget from the begin play and store a pointer to it. Approximately around 1 min and 30 seconds running the game when I open My inventory UI the engine crashes
UObjects member fields should be tagged as UPROPERTY so they are properly managed. You can use UPROPERTY only if your containing class is also a UObject. If it is not, then implement the FGCObject interface
Example 1:
class UOwnerClass : public UObject {
public:
UPROPERTY()
UUserWidget* MyWidget;
};
Example 2:
class FOwnerClass : public FGCObject {
public:
virtual void AddReferencedObjects( FReferenceCollector& Collector) override {
Collector.AddReferencedObject(MyWidget);
}
private:
UUserWidget* MyWidget;
};
Hi thank you for replying. I’m quite not familiar with the FGCObject Interface yet. Does that mean I would handle the GC of my widget?
I’ve already tried to add UPROPERTY It still marks my widget as garbage automatically.
Hi. I had 1 Uobject in my userwidget that is not set to UPROPERTY(). it finally worked! Thank you so much!