x

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"

TSoftObjectPtr referenced assets not packaged

Hello,

So I am pretty sure this is an engine bug, but I wanted to make sure I'm not doing somthing wrong before creating a bug report. Basically the issue seems to be that an asset referenced via TSoftObjectPtr is not included in a packaged build if it is set via C++ in the constructor, it does however work when the pointer is set through the defaults panel of a child blueprint class.

This is what my code looks like:

 UPROPERTY(EditAnywhere)
 TSoftObjectPtr<USoundBase> SoundAsset;

 ASomeActorClass::ASomeActorClass()
 {
 SoundAsset = FSoftObjectPath("/Game/Sounds/MySoundAsset");
 }

In a packaged build the string path in the reference is set, however trying to load it results in this warning in the log:

 LogStreaming: Error: Couldn't find file for package /Game/Sounds/MySoundAsset requested by async loading code. NameToLoad: /Game/Sounds/MySoundAsset
 

The issue is not that the pointer isn't a UPROPERTY, neither that I'm referencing an asset that does not exist outside of editor builds. It does work when I assign the asset via the defaults panel in the child blueprint class, it also works when I use a hard pointer in C++.

Any thoughts?

Product Version: UE 4.20
Tags:
more ▼

asked Mar 19 '19 at 12:47 PM in C++ Programming

avatar image

Fluppi393
457 35 33 54

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

You will need to add the directory to be cooked in the DefaultGame.ini (can be done in Project Settings). You will need to add the folder that the asset is in:

+DirectoriesToAlwaysCook=(Path="Sounds")

The code is not scanned for any references so according to the Engine, the assets are not references anywhere so you will need to manually do it.

more ▼

answered Mar 19 '19 at 04:24 PM

avatar image

Dune
1.9k 52 40 200

avatar image Fluppi393 Mar 19 '19 at 04:42 PM

I do know that I could set certain directories to always cook, however that is more of a workaround, prone to errors when forgetting to add a folder and will also include assets that are not referenced at all. I don't know exactly how the cooking process works, if you know more about it I would be glad if you could share it. As far as I know you can reference assets purely in C++ UObject derived classes, for example if I load an asset via ConstructorHelpers::FObjectFinder and assign it to a UPROPERTY hard pointer it will be cooked. But this soft pointer isn't even purely in a C++ class, I made a child blueprint class where I can see the correct asset assigned in the details panel. The blueprint itself is cooked, but not the asset. If I don't set the asset reference in C++ and instead select it from the details panel, it will be cooked.

I made a little example project to confirm the bug, basically when you PIE you will see two particle systems, when you run a packaged build you will only see one: https://drive.google.com/file/d/19ziTy5qy9YkuRiYqrNkEEd6fT4n24dBO/view?usp=sharing

(comments are locked)
10|2000 characters needed characters left
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