Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bolt Custom Fuzzy Finder Menu Hierarchy?

Discussion in 'Visual Scripting' started by ModLunar, Sep 27, 2020.

  1. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    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:

    upload_2020-9-26_22-13-56.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)
     

    Attached Files:

    Last edited: Sep 28, 2020
  2. MasterSubby

    MasterSubby

    Joined:
    Sep 5, 2012
    Posts:
    252
    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.
     
    Kennth and ModLunar like this.
  3. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    Great, thanks!

    So in that case, I could use the following to put something under the Variable menu?
    Code (CSharp):
    1. [UnitCategory("Variables/Example")]
    And there's no C# constants I can use instead of magic strings (literals), right?
     
  4. MasterSubby

    MasterSubby

    Joined:
    Sep 5, 2012
    Posts:
    252
    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.
     
    ModLunar and Kennth like this.
  5. MasterSubby

    MasterSubby

    Joined:
    Sep 5, 2012
    Posts:
    252
    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<T> 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.