Use the If Then Else patch to switch between two states in response to something depending on the data type selected.
Name | Description |
---|---|
Condition | Connect to the patch causing something to happen. For example, if you want a screen tap to cause something to happen, connect a Screen Tap patch to the If Then Else patch. |
Then | Depending on the data type selected, enter a value for when the condition is met. For example, if you want an object to change color when the condition is met, use the Color data type and select a color. |
Else | Depending on the data type selected, enter a value for when the condition is met. For example, if you want an object to change color when the condition is not met, use the Color data type and select a color. |
Name | Description |
---|---|
Output | Output the signal to the next patch. |
In the example below, we see the color of an object switch between blue and pink each time the screen is tapped.
To make the object color change, we used the following graph:
We connected:
The Tap output on the Screen Tap patch to the Flip input on the Switch patch. This makes a screen tap the condition for changing the object’s color.
The On/Off output on the Switch patch to the Condition input on the If Then Else patch.
When a screen tap is registered, the flip is turned on and a check appears to the right of Condition. The condition has been met, so the object material takes the property of the Then input on the If Then Else patch.
When a screen tap is registered again, the flip is turned off and the check to the right of Condition disappears. The condition is not met, so the object material takes the property of the Else input on the If Then Else patch.