Are using soft references pointless when it comes to saving space and stuff? And if so, is there still a use case. I am using UE5.7 preview and I am finding that in a GASP project, even if I create an BP actor and attach a Character blueprint variable to that blank actor, that when using the SizeMap feature says its 1GB, however, on paper, it had no affect. If I go to the project file in my documents and click properties to view the file size it didnt include the new “1 gb” bp actor file. When I build a shipping version of the game, and do one version with that BP actor references the 1GB variable, and one without referencing it, the file sizes are exactly the same.
So, what would be the point now in using soft references if this finding is the case?
Edit: think I realize now, its more so about how it loads and avoiding noticeable hitches if I do not need a character right away but might need to load it in game later. So the only time to use a soft reference is when I didnt drag it into the viewport, and instead need to spawn the character or actor. Is that correct?
Hey there @CVoiceOfficial! As you noted in your edit, soft references are best used to control when and if something is added to memory more than anything else. This functionality is extremely useful when you don’t need to have the actual actor in scene at launch, or you want to be able to prepare a reference before you actually have the thing it’s referencing created.
Hi there, soft references are very valuable, but must be used exceedingly cautiously to work correctly. If the large assets are still shown in the size map, it’s likely you have a hard referencing in there which is overriding the soft ref.
Common examples of this would be casting to that actor (because the ouput node is a hard ref, storing that actor as a variable once it’s loaded into memory from the softptr, calling functions on the actor which exist in the actor bp itself. And as you mentioned using the CreateActor node means you must put a hard reference of that actors class in which requires it to be in memory, you would need to use a soft class ptr and ideally change it to a base class or interface to be spawned.
To get around these, you would have to cast to a base class which contains the functions or stub functions overridden in the main actor bp to do actual functionality, or using interfaces. You can also just use the LoadAsset output variable which gives you a generic “UObject” type and passthat into most nodes, casting it to the lowest possible engine class where possilbe such as “AActor” rather than your actual bp.
Another workaround is to always pass around a code class only, never a bp class. If code has all the functionality in including stub functions if that’s how your project is setup then it would also work.
As a general rule, if you hover over any nodes and they tooltip shows the actual class/bp then it’ll be a reference.