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"

Spawn new Box Brush in C++

Like a topic name. The best answer would be a function to spawn brushes during the game. I know the answer from: https://answers.unrealengine.com/questions/100323/how-to-create-spawn-boxes-with-box-brush-in-c.html but I am still not convinced. I want to test it myself. Also, one would consider creating complicated objects with brushes in editor (like fractal-like structures), which is obviously not possible without scripting.

Product Version: UE 4.13
more ▼

asked Oct 30 '16 at 10:00 PM in C++ Programming

avatar image

132 12 10 22

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

2 answers: sort voted first

I have found it, and it took me (only) two days. To be honest it's not that hard, but unnecessary complicated - maybe it will evolve into pull request of source code. Here is the code which I used to spawn new Box Brush:

 UWorld *World = GEditor->GetEditorWorldContext().World();
 ABrush *NewBrush = World->SpawnBrush();
 NewBrush->BrushBuilder = NewObject<UBrushBuilder>(NewBrush, UCubeBuilder::StaticClass(), NAME_None, RF_Transactional);
 NewBrush->Brush = NewObject<UModel>(NewBrush, NAME_None, RF_Transactional);
 NewBrush->Brush->Initialize(NewBrush, false);
 NewBrush->BrushType = EBrushType::Brush_Add;
 NewBrush->BrushBuilder->Build(NewBrush->GetWorld(), NewBrush);

Honestly, it needs some tutorial or explanation in Documentation. Single SpawnBrush function SHOULD get you complete and usable object, not empty uninitialized actor. Also, SpawnActor function is used only 3 (three!) times in source code, according to GitHub.

more ▼

answered Oct 31 '16 at 01:35 AM

avatar image

132 12 10 22

avatar image VincentJun Dec 05 '16 at 11:50 AM

hello, can you spawn a box brush? why did i can't compile four line UCubeBulider must be a class or namespace name,seven line pointer to incomplete class type is not allowed.......please help me ..thanks

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

what's the version of your UE4

more ▼

answered Nov 17 '16 at 06:23 AM

avatar image

1 1

avatar image VincentJun Dec 05 '16 at 12:10 PM

in the end can you solve this problem? if you have a good idea ,can you share for me?

avatar image ZaruWright Jun 18 '18 at 01:13 PM

You have the answer on the following link https://answers.unrealengine.com/questions/25346/how-to-use-editor-classes-from-within-an-actor-cla.html.

Basically you have to add the UnrealEd module Into your Build.cs file. You have to have something like this:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UnrealEd" });

And recompile your project again.

(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