Step 5 - Gauges transitions

In this step, you create the transitions between the gauge styles and shapes.

../_images/preview-gauge-shape-style.gif

Create gauge style and shape transition

To create the gauge shape and style transition:

  1. In the Node Tree, in the Cluster Components_2375:687 > Cluster Components:

    1. Delete the GaugePlaceholderRight and GaugePlaceholderLeft nodes.

    2. Create an Empty Node 2D node and name it Gauges.

    3. From the Library > Property Types > Control, drag the GaugeShape and GaugeStyle properties to the Gauges node.

    ../_images/node-tree-gauges.png ../_images/properties-gauges.png ../_images/library-control-gaugeshape-gaugestyle.png
  2. In the Gauges node, create an Empty Node 2D node, name it SpeedoMeter. In the Properties, and add and set:

    • Layout Width and Layout Height to 720

    • Horizontal Alignment to Left

    ../_images/node-tree-speedometer.png ../_images/properties-speedometer.png
  3. In the SpeedoMeter node, create an Empty Node 2D node, name it ShapeRect. In the Properties, and add and set:

    • 01 Configuration > Gauge Shape Control to Rect

    • Render Transformation Origin property field Y to 0.5

    ../_images/node-tree-shaperect.png ../_images/properties-shaperect.png
  4. In the ShapeRect node, in the Properties click Add Binding, and bind:

    • isActive property to

      {@./Control.GaugeShape} == {#Control/Control.GaugeShape}
      
      ../_images/binding-shaperect-isactive.png
    • Node > Visible property to

      CEIL({@./Node.Opacity})
      

      When Opacity is 0, this binding sets the Visible property to false. This way the node is not rendered when not active.

      ../_images/binding-shaperect-visible.png
    • Render Transformation property field Translation X to

      -{@./Support.OffsetX}
      
      ../_images/binding-shaperect-translation-x.png
    • Render Transformation property field Scale X to

      {@./Support.Scale}
      
      ../_images/binding-shaperect-support-scale.png
  5. In the Node Tree, duplicate the ShapeRect, and in the Properties set:

    • Name to ShapeRound

    • 01 Configuration > Gauge Shape Control to Round

    • Render Transformation Origin property field X to 0.5

    • Change the Render Transformation property field Translation X binding to bind to Rotation Z and edit the binding

      -{@./Support.OffsetX}/10
      
      ../_images/binding-shaperound-rotation-z.png
    • Duplicate the Render Transformation property field Scale X binding and set it to bind to the Scale Y property field.

      ../_images/binding-shaperound-scale-y.png
    ../_images/node-tree-shaperound.png ../_images/properties-shaperound.png
  6. Create a tachometer:

    1. Duplicate the SpeedoMeter node, rename it to TachoMeter. In the Properties, set the Horizontal Alignment property to Right.

      ../_images/node-tree-tachometer.png ../_images/properties-tachometer.png
    2. In the TachoMeter > ShapeRect and ShapeRound nodes, in the {@./Support.OffsetX} bindings, remove the minus sign.

      ../_images/binding-tachometer-shaperect.png ../_images/binding-tachometer-shaperound.png
    3. In the TachoMeter > ShapeRect, set the Render Transformation Origin property field X to 1.

      ../_images/node-tree-tachometer-shaperect.png ../_images/properties-tachometer-shaperect.png
  7. From the Prefabs, drag these prefabs to the nodes in the SpeedoMeter and TachoMeter nodes:

    • SpeedoMeter > ShapeRect

      • Speedometer_Simple_Rect_2024:2036

      • Speedometer_Rich_Rect_2134:1222

    • SpeedoMeter > ShapeRound

      • Speedometer_Simple_Round_2024:2035

      • Speedometer_Rich_Round_2158:1294

    • Tachometer > ShapeRect

      • Tachometer_Simple_Rect_2024:2034

      • Tachometer_Rich_Rect_2134:1223

    • Tachometer > ShapeRound

      • Tachometer_Simple_Round_2024:2033

      • Tachometer_Rich_Round_2158:1295

    ../_images/node-tree-gauges-ready.png
  8. Select all Rich prefabs and temporarily hide them by pressing Ctrl H.

    ../_images/node-tree-gauges-ready-hide-rich.png
  9. In the Library, create a State Manager and name it Shape Switch State Manager:

    • Select the State Group and in the Properties:

      • Set the Controller Property to isActive

      • Under the State Transitions property, click Add transition and set:

        • Duration to 500 ms

        • Easing Function to Cubic

        • Easing Mode to Ease in-out

      ../_images/properties-state-group-shape-switch.png ../_images/state-transition-settings-shape-switch.png
    • Rename the states to Active and Inactive, and in each add and set:

      • Active state:

        • isActive to enabled

        • Node > Opacity to 1

        • Support > OffsetX to 0

        • Support > Scale to 1

      • Inactive state:

        • isActive to disabled

        • Node > Opacity to 0

        • Support > OffsetX to 720

        • Support > Scale to 0

      ../_images/properties-shape-switch-state-manager-active.png ../_images/properties-shape-switch-state-manager-inactive.png ../_images/library-shape-switch-state-manager.png
  10. In the Node Tree, in the Gauges > SpeedoMeter and TachoMeter nodes, select ShapeRect and ShapeRound nodes. In the Properties, add the Resources > State Manager property and set it to Shape Switch State Manager.

    Now you can test the shape switch functionality for the simple gauges by changing in the Control node the value of the Gauge Shape Control property.

    ../_images/node-tree-gauges-simple.png ../_images/properties-gauges-simple-state-manager.png ../_images/preview-gauge-shape.gif
  11. To switch the gauge style between simple and rich, create a State Manager and name it Style Switch State Manager:

    • Select the State Group and in the Properties:

      • Set the Controller Property to isActive

      • Under the State Transitions property, click Add transition and set:

        • Duration to 1000 ms

        • Easing Function to Cubic

        • Easing Mode to Ease in-out

      ../_images/properties-state-group-shape-switch.png ../_images/state-transition-settings-shape-switch.png
    • Rename the states to Active and Inactive, and in each add and set:

      • Active state:

        • isActive to enabled

        • Opacity to 1

      • Inactive state:

        • isActive to disabled

        • Opacity to 0

      ../_images/properties-style-switch-state-manager-active.png ../_images/properties-style-switch-state-manager-inactive.png ../_images/library-style-switch-state-manager.png
  12. To all Simple and Rich prefabs, add:

    • 01 Configuration > GaugeStyle property and set it to the corresponding style for each prefab

    • Resources > State Manager property and set it to the Style Switch State Manager

    • Bind the isActive property to

      {@./Control.GaugeStyle} == {#Control/Control.GaugeStyle}
      
      ../_images/binding-shaperect-simple-isactive.png
    • Bind the Visible property to

      CEIL({@./Node.Opacity})
      
      ../_images/binding-shaperect-simple-visible.png
    ../_images/node-tree-speedometer-shaperect-simple.png ../_images/properties-speedometer-shaperect-simple.png
  13. Select all Rich prefabs and press Ctrl H.

    ../_images/node-tree-gauges-rich.png

You can now control the gauge shape and style in the Control node with the Gauge Shape Control and Gauge Style Control properties.

../_images/preview-gauge-shape-style.gif