Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Undocumented features - Variables in the unit header

Discussion in 'Visual Scripting' started by ChaosCraft, Aug 8, 2022.

  1. ChaosCraft

    ChaosCraft

    Joined:
    Feb 8, 2022
    Posts:
    7
    I hope to collect up some of the features of the system that appear undocumented.
    I'll post any I find here under the "Undocumented features" tag.

    If anyone can point to doco for them that's even better.

    Today's offering is the UnitHeaderInspectable Attribute

    This lets you add a field that you can configure in the header of the unit, but that is not a port. Basically a config value. I've not experimented with if it needs to be serializable, nor with whether the header can be made to minimize if there are too many fields.

    for example,
    Code (CSharp):
    1.     [UnitHeaderInspectable("min")]
    2.     public int minCount = 1;
    3.     [UnitHeaderInspectable("max")]
    4.     public int maxCount = 1;
    creates...
    UnitHeaderInspectable.png


    Duplicate names are allowed (though that would be confusing), order appears to be order of declaration. The header does not offer any way to minimize by default.

    Anyway, I hope this helps someone.
    If anyone knows a way to move these into the Graph Inspector, that'd be awesome (less crowding of the graph), and I'd love to get access to the source code if I could so I can explore more of these sort of attributes etc.

    Found any yourself? Please share them. I'm loving visual scripting, but the doco side of it is very thin for something so powerful.
     
  2. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    355
    If you want some variables that are not ports, you can just make a variable [Inspectable]. Think that might work on UnitHeaderInspectable but not sure. The best document is the code, also the bolt addons code which extends it (hence how to extend/customise). Just make packages show in your solution, and all the code is there.
     
  3. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    355
    You can also use the UnitHeaderInspectable to show information (I used it with a stopwatch to show frame times). There lots of funky things you can do, it's very customisable in my opinion, but that's a learning curve. Here's an example of funky, but I never got round to finishing. Portal Node (newline node):
     
  4. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    355
    UnitHeaderInspectable as an average ticks output: upload_2022-8-8_8-38-47.png