Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Async loading assets directly to a hard reference?

So I read about TSoftObjectPtr and FStreamableManager for async loading.

Those work great but the thing is the requresting a async load gives you a weak pointer to the object which you then need to assign to a hard reference.

The issue with that is you need to maintain two variables for each asset you want to load using FStreamableManager one is the TSoftObjectPtr and the second being a hard reference (UProperty, shared ptr etc) to the object.

Is there a way to get a hard reference on the TSoftObjectPtr itself after you've loaded it?

I've read about SimpleAsyncLoad but that makes a permanent hard reference and needs manual unloading which leaves plenty room for resource leaks.

I wish to load supporting assets in the begin play and then have them automatically unload as it goes out of scope or is destroyed but without the need to maintain two different variables for each asset.

Product Version: UE 4.20
more ▼

asked Aug 04 '18 at 10:25 AM in C++ Programming

avatar image

Commander Shepard
817 62 83 220

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Yes LoadSynchronous function will only load when needed


but most impolitely TSoftObjectPtr has operator overloads for * and -> and they return main object, so TSoftObjectPtr it self behaves like pointer

https://api.unrealengine.com/INT/API/Runtime/CoreUObject/UObject/TSoftObjectPtr/op_deref/index.html https://api.unrealengine.com/INT/API/Runtime/CoreUObject/UObject/TSoftObjectPtr/operator/index.html

more ▼

answered Aug 04 '18 at 03:17 PM

avatar image

37.3k 936 172 1117

avatar image Commander Shepard Aug 05 '18 at 05:24 PM

well as per the docs TSoftObjectPtr are weakptrs so it may get garbage collected and need to be loaded again, hence its not good to use them directly

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question