Macro for Editor

Poinball 2 years ago updated by Lazlo Bonin (Lead Developer) 8 months ago 22 2 duplicates

Hey, I already talked to you about it 3 month ago and I didnt see it in your roadmap. 

It would be really usefull to be able to write code that can work in the editor. Maybe a Editor Macro.

Unreal Blueprint system have it. It is called Consctruction Script. It allow us to create script for repetitive task like this : 

We could have different event that detect things that we do in the Editor. 
trigger a script with a button or a keyboard shortcup...

Thanks ! :)  

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Duplicates 2

Can you clarify what that means?

Just an idea I had. You would add a special event called "Inspector Button" in a flow graph and give it a label. Then, in the inspector for that flow machine, a button with that label would be added, and when you click it, even when in edit-mode, the associated event would be triggered.

This would let you do cool editor scripting right within Bolt. For example, you could have graphs to generate a procedural map, and trigger them from the inspector with that event.

Very good idea if it can be implemented.

Pending Review

Merging with another Idea topic, let me know if that's what you meant.

Hey Lazlo

This sounds like a good start :)

However ideally I would like not to have to press a button. A "Force refresh"-button would still be good to have but ideally the event would be triggered automatically when the gameobject is moved, when a subobject of the gameobject is moved or when a variable changes.

To put this into context; in UE4 I would use blueprints extensively for world building. I would make "deco" objects which ie. could be a collection of objects that were z-projected onto whatever they would collide with. This was a quick way to add lots of ground detail such as shrubs, rocks etc etc. The placement of these subobjects would be updated automatically whenever the parent was moved. Having to press a button with Bolt for this update to be triggered would get annoying quickly as part of the value by doing it this way was the instant visual feedback you got.

Hope this explains well enough but please let me know if you are unsure what I mean.


I read the documentation on construction scripts after your comment and I must say I'm a bit confused.

If you create objects during the construction script (e.g. add deco), do they get deleted when the construction script re-runs? How does it know that these objects are "bound" to this script?

What exactly is the event that triggers a construction script? Creating an object? Moving an object? Having a parent or child in its hierarchy change? 

As I understand it the construction script is run when the gameobject is first added to the scene, when it is moved, when a hierarchical subobject is moved or when a variable change.

Adding to that a force refresh button would also be a good idea for situations where the construction is not called automatically.

If the spawned objects are not a hierarchical child I guess it could also be up to the user to create an array in the flowgraph to keep track of spawned objects and then call the desired changed on those objects when the construction script reruns.

I havent really worked much with blueprints for some time (since switching to unity) so excuse me that I cant give you an exact answer how the construction scripts work :)

I guess an option to add the executeineditmode attribute is really what I am asking for - ?

Hmm. Seems very similar to what assets like Octave3D and ProCore do to add and manipulate objects/prefabs in editor/scene. That could be useful as an option. 

The problem with ExecuteInEditMode and similar approaches is that any object you create will be permanent and won't get magically destroyed if you execute the creation code again. I'll look into how I could do it, but the traditional Unity approach is not to generate elements by script automatically, rather to create a custom editor (or button) and save prefabs.

Thank you for this brief explanation and very nice information. Well, got a good knowledge. Sometimes you just have to yell at people and give them a good shake to get your point across.


That's actually pretty simple to implement, but my plate is full right now. 

Perhaps you could ask one of the users who make the community addons to create that custom unit?

Basically, it can be an Event unit that shows a button in its widget header, and if that button is clicked, it triggers. It would have all the same limitations as the On Draw Gizmos event (e.g. no state/instanced variables access) but it should work!

I though that it would require a new set of nodes to work in the Editor intead of at runtime .

Well thanks to put it in the roadmap :)


Nope, every Bolt node already works in the editor, it's just a matter of triggering them!


Lazlo sent out the BAC call, and Jason came out of retirement to hook you up:

It'll be in the next release!

Thanks guys! True life savers! :)

Awesome !! Thanks :D


(Sorry for the bump/necro, I'm doing some roadmap grooming following the Unity acquisition!)

This is now supported in Bolt 2. Function graphs can be invoked using a button in their instance's inspector.