Search Unity

Question Displaying/hiding or enabling/disabling custom unit variables depending on another variable

Discussion in 'Visual Scripting' started by John1294, Jan 18, 2022.

  1. John1294

    John1294

    Joined:
    Apr 28, 2016
    Posts:
    7
    Hi visual scripting community,

    so I am currently using custom units in my project and run into a problem/limitation. I want to have variables to be shown/hidden or enabled/disabled during development depending on the set state of another variable.

    So I know that it's possible to enable/disable a ValueInput based on the set option in a
    UnitHeaderInspectable and then checking this UnitHeaderInspectable in the Definition of the node. (See Option3 in the picture attached) This is fairly easy, but doesn't solve my problem.

    Is it possible that a UnitHeaderInspectable could be enabled/disabled or shown/hidden based on the value set to another UnitHeaderInspectable (See Option 1 in the picture attached)? I feel like that might not even be possible and would be the less preferable option for what I am trying to do.

    Alternatively and probably preferably, could a ValueInput be displayed/hidden or enabled/disabled based on the set state/option of another ValueInput during edit time? I feel like this might be possible through the Definition, but obviously I don't have the "Flow" in the definition to check the variable and from what I can find, I can only read out the default value of a ValueInput.

    Maybe It's actually not possible, as there is probably a reason UnitHeaderInspectable and ValueInputs exist, but maybe somebody knows a solution. I also take dirty workarounds if somebody has an idea ;)

    Custom Units.JPG
     
  2. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    I think the only way might be to draw your own Widget, in the Widget you would define what you want to display, but since you are overriding the whole thing it might take a bit of work.
     
  3. John1294

    John1294

    Joined:
    Apr 28, 2016
    Posts:
    7
    Thanks for the input, drawing the whole widget manually is probably not feasible and would take too long to do. Are there no easier solutions?
     
  4. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    I think with a custom widget, just copy/override the whole code for CachePosition from UnitWidget, and where it says if(showSettings) just put some clause to set the width/height to 0. Might work. I think the top variables are called 'settings' anyway.