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"

Unitialized DataAsset in AActor::OnConstruction

In the project I'm working on I'm using the OnConstruction function in an actor to update some properties using a custom DataAsset everytime the actor is moved in the editor. As long as I'm editing the level or it's the first level loaded into the editor this is fine, but if the editor opens to a different level and I then load the level my actor is in then the DataAsset I'm using just isn't initialized.

I repro'd this with the following steps:

  1. Create a new C++ project with a blank template

  2. Add 2 C++ classes to the project: one DataAsset and one Actor

  3. Add a float UPROPERTY to the DataAsset class, defaulted to 0.0f

  4. Create a new instance of your DataAsset in the editor, change the float value to some number greater than 0

  5. Override the OnConstruction function in the actor class from step 2, call LoadObject and get the object from step 4

  6. Add check(asset->floatProperty > 0.0f); to the OnConstruction function

  7. Create a new level in your project, put an instance of your actor into the level

  8. Make sure "Edit->Editor Preferences->Loading and Saving->Load Level at Startup" is set to "None"

  9. Restart the editor

  10. Load your level from step 7

This should cause the check from step 6 to fail. I have found that a workaround for this is to open the DataAsset from step 4 in the editor before opening the level but that's not foolproof since it's entirely possible to forget to so that (or just not know that's required since I'm not working by myself).

Attached here is the repro case that I created. This also occurs in 4.12 so doesn't seem to be a new bug.

Product Version: UE 4.13
dataassetcrash.zip (10.5 kB)
more ▼

asked Sep 27 '16 at 11:13 PM in Bug Reports

avatar image

919 40 58 204

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

1 answer: sort voted first

Hey kgamble-

I was able to reproduce the error (the check not being triggered) when using File->Open Level to open the level from step 7. However I also found that by double clicking on the level asset in the content browser I did get the check to trigger. This leads me to believe that, rather than the data asset not being initialized, there is a difference in the way the level is loaded that is causing the issue. This difference in level loading has been reported here: https://issues.unrealengine.com/issue/UE-36532 . You can track the report's status as the issue is reviewed by our development staff.


Doug Wilson

more ▼

answered Sep 28 '16 at 02:35 PM

(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