A question about pointers to assets

When we are creating pointers in the header file to assets like widgets, sounds etc, I don’t understand how they can be pointers.
Pointers look at a location in memory, but these assets haven’t been loaded into memory yet, so how can Unreal point to their location? Or is everything in the content browser loaded into memory?

For example…

UPROPERTY(EditAnywhere)
USoundBase* ImpactSound;

It’s pointing to the ImpactSound, but the ImpactSound asset hasn’t been loaded into memory yet (obviously where my understanding is lacking)

Thanks in advance!

This is an Unreal Engine question you posted to the Unity group. You may find more answers if you change the group to Unreal Engine.

Apologies, thank you for redirecting.

With my limited understanding of C++ and UE, I can say this;

USoundBase* ImpactSound;

doesn’t point to anything. It is a definition. It states that we have a property called ImpactSound that is of type USoundBase and we will store a pointer in here. Once an asset is assigned to ImpactSound, then only will it have a pointer to that asset. Iirc, the UProperty bits makes it show up in UE editor so that you can assign assets to it there. Then it will have a place in memory to point to.

No, the fact that this is called ImpactSound and you have an asset called ‘ImpactSound’ is purely conincidental. There is no relation until you assign the ‘ImpactSound’ asset to the ImpactSound property

Right OK, thanks! So when an asset is assigned to that pointer, it loads the asset into memory?

Yeah, I think so. This would be at runtime. The editor may load it into memory to do stuff with it, but I don’t really know.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms