Bolt Custom Fuzzy Finder Menu Hierarchy?

I created 2 classes that inherit from the Bolt.Unit class.
They appear in the Fuzzy Finder window after selecting Tools > Bolt > Build Unit Options in Unity as such:

6353541--706533--upload_2020-9-26_22-13-12.png

(Called "Example Unit" and "Dialogue Line Unit" in the example screenshot above).

However, I anticipate making a lot of custom Units in the near-future.
How do I edit where they are organized under? (Similarly to the [CreateAssetMenu(menuName = "...")] attribute for ScriptableObjects in the right click "Create" menu)

6353541--706533--upload_2020-9-26_22-13-12.png
6353541--706533--upload_2020-9-26_22-13-12.png

Very simple attribute for this:
[UnitCategory (string category)]

A couple things to note, there are specific categories you need to have as the root category when making certain type of Units. For instance, all Event units just start in the Events category. Any sub category can be appended to that. Same with variable or nesting units must be in Variable and Nesting as the root.

2 Likes

Great, thanks!

So in that case, I could use the following to put something under the Variable menu?

[UnitCategory("Variables/Example")]

And there's no C# constants I can use instead of magic strings (literals), right?

This is the usual recommended way. There is a way to Dynamically add units how variables and macros do it, but I haven’t gotten around to that just yet. Other then those, not that I know of.

Yes though, that’s the proper way in your example.

2 Likes

Actually just found out how to do dynamic fuzzy finder options.

I may do a tutorial around this when I have time, but the essential thing is having two scripts. One is a static class with a static constructor. In its constructor you’ll add your unit options to the static dynamicExtensions list Bolt has in maybe, UnitBase? Can’t remember.

The other one is inheriting from UnitOption for each option you want to have. The static class yields over these options. I’ll grab a gist later of the two scripts, but that’s a little run down to my latest findings. It’s pretty powerful, as you can prefill instances of a unit in the finder, that will be Instantiated that way. Same way variables work. Then you can search for those instances instead of adding a unit then filling it manually.