AddReferencedObjects . How it works?

Hi! I do not understand how I can add reference Object1 to Object2. Where can I get link to FReferenceCollector. Are there examples?

p.s. Sorry for my good English :slight_smile:

As you can see in UObject::AddReferencedObjects() or AActor::AddReferencedObjects(),

void AActor::AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector)
{
	AActor* This = CastChecked<AActor>(InThis);
	Collector.AddReferencedObjects(This->OwnedComponents);
	Super::AddReferencedObjects(InThis, Collector);
}

You can make your own AddReferencedObjects() function in your class as far as the class is derived from UObject.

By the way, just giving UPROPERTY() to your class member variable is enough for most situations.

Thank you but I think it’s not actual anymore since there is function AddToRoot().