How can I understand the data member 'Outer' in the UObjectBase class

Hello everyone,my question is simple,but confuse me very long.I always don’t konw the clear mean about the Outer member in the UObjectBase class.
In my view, if a member in class A named ‘m’ which is derived from UObject,so,I think the outer class of ‘m’ is A.
Is my understanding all right?
Can anybody tell me a exactly answer?
Thanks very much!

1 Like

An object’s “Outer” is the object which “owns” it. For instance, a Component is owned by its Actor or parent component, and Actors are owned by their Levels. Whenever you construct an object of a class derived from UObject, you provide it with an Outer. (CreateDefaultSubobject implicitly provides the current object as the Outer.)

Sometimes an object will have a pointer to some other object without owning that object. For instance, UNavMovementComponent has a pointer to its sibling UPathFollowingComponent. In that case, the UPathFollowingComponent will not have UNavMovementComponent as its Outer.

4 Likes

Thanks !
You say An object’s “Outer” is the object which “owns” it. Can I understand the “owns” means relationship of the gameplay classes?
In the UE4 gameplay programing frame,I know actor is a container of component, Levels can have many actors,Map can have many levels. So,can I get to understand level’s outer is map?
Thanks!

Generally it has that relationship, but not always. A ULevel’s outer is a UWorld (basically a map). But a child actor’s Outer is the Level, not the owning UChildActorComponent.

Thanks very much for resolving my question.

if I destroy an actor, which is the outer of a component, the component will also be destroyed?

I believe it will be left without a parent so it will be garbage collected on the next iteration of the GC

1 Like