Why does a function's local variable of type AssetID resolves to None?
Hello, While trying to understand the AssetID variable type, I stumbled upon a problem that I don't get.
I have a custom DataAsset called MyDataAsset created in code:
Then I created an asset called NewDataAsset of type MyDataAsset:
Then I creat an Actor with a NewDataAsset variable of type AssetID, and a function that prints the String value:
But if I use instead a local variable, the Resolve AssetID node resturns None:
Why is this happening? I can't create objects using an AssetID with local variables?
The idea of Asset ID is to keep weak reference to an asset on your hard disk it can be anything!, It is I think C++ equivalent of FStringAssetReference/TAssetPtr ( look : HERE ).
To give you a bit of an outline as to why it is so important. Think about a scenario where you have references to say e.g 1000 textures on hard disk, it will stall your main thread if you try and load 1000 textures into memory all at once on game thread, you should avoid this and always show some kind of throbber or wait symbol whilst loading a large asset ( can be anything ).
So to answer your question, a better way to do it would be to do an async/non blocking load which notifies you via delegate callback once the asset is done loading. See image below which takes AssetID as input parameter and triggers output once asset is done loaded with loaded asset pointer.
Use that function to fire off an async load and then use the output object and it should not be None anymore. Hope this helps
answered Sep 21 '15 at 01:15 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here