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"

[Closed] StaticLoadObject doesn't work in a packaged game.

Hello all.

I want to create an Actor in C++, and this Actor is defined with Blueprint.

So, I tried this code below.

 UClass* Class = NULL;
 UObject* uobj = StaticLoadObject(UBlueprint::StaticClass(), NULL,TEXT("Blueprint'/Game/Project/Blueprints/TestCharacter.TestCharacter'"));
 if (uobj != NULL) {
     UBlueprint* blueprint = Cast(uobj);
     Class = blueprint->GeneratedClass;
 }
 
 FTransform SpawnTransform;
 FActorSpawnParameters SpawnParameters;
 SpawnParameters.SpawnCollisionHandlingOverride = CollisionHandlingOverride;
 AActor* act = GetWorld()->SpawnActor(Class, &SpawnTransform, SpawnParameters);
 

It works fine when I run this in the UE4Editor.

But in a packaged game, StaticLoadObject() returns NULL.

In addition, I could create this Actor from Blueprint-to-C++ function like this in the same packaged game.

So, I think 'TestCharacter Actor' is cooked and included in a game package.

 AActor* AMyTest::SpawnActor(UClass* Class, FTransform SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride)

I'm using UE 4.10.1, and packaged for Windows 64bit.

Could you give me some advices?

Thanks in advance.

Product Version: Not Selected
Tags:
more ▼

asked Mar 03 '16 at 09:09 PM in Packaging & Deployment

avatar image

Answers.Archive STAFF
1.9k 209 316 689

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

The question has been closed Mar 03 '16 at 09:09 PM by Stephen Ellis for the following reason:

The question is answered, right answer was accepted


1 answer: sort voted first

Hello Tatsuya-

Blueprints are defaulted to be stripped out when cooking. This can be overridden in the DefaultEditor.ini file by changing "bDontLoadBlueprintOutsideEditor" from true to false. After making this change and packaging again the result in the packaged version should match what is seen in the editor / standalone.

Cheers

Doug Wilson

more ▼

answered Mar 03 '16 at 09:09 PM

avatar image

Answers.Archive STAFF
1.9k 209 316 689

avatar image Answers.Archive STAFF Mar 03 '16 at 09:09 PM

Hi Doug, I want to say thank you! It solved my issue.

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

Follow this question

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

Answers to this question