Adding rules to define complex Variant logic
By default, the system exports your configurator with any Variants that you mark as Active in the Product tab. All Active Variants are available for consumers to select in your configurator application.
If you want to display or hide certain Variants when consumers select different options in your application, you must add specific rules that define the behavior you want in the Rules tab. For example, you can add a rule that makes the configurator display different Variants of your product depending on the country the consumer selects in the application.
You can also make it so that when a consumer makes a selection, other Variant Sets or Pack Sets are automatically selected.
To add Rules for your configurator, do the following:
- In the Unity Forma interface, select the Rules tab.
- Select Add and then select Rule.
- In the Name field, enter a name for the rule.
- In the Description field, type a meaningful description for the rule.
- Under If, use the left drop-down field to select the Variant Set, Pack Set, or Context that activates this rule. For example, to select a specific Market.
In the right drop-down Condition field, select the state you want to activate this rule. For example, "Market is English". Conditions for Pack or Variant Sets will have the "Selected" and "Not Selected" state available.
In the Then drop-down button on the left, select one of the following:
- To make the configurator display an option when your Condition is True, select Available.
- To make the configurator disable an option when your Condition is True, select Not Available. Note that some UIs will instead hide the option when Not Available is used.
- To make the configurator hide an option when your Condition is True, select Hidden.
- To make the configurator displays a an option with changes when your Condition is True, select Available with Changes.
This option requires a script extension.
- In the left drop-down box under Then, select the Variant Set or Pack Set that you want the configurator to display or hide when your Condition is True.
- Add more rules as needed.
Advanced Rule Setup
The previous section outlined the steps behind a simple If condition then do action rule. The Rule engine is capable of more advanced logic, such as multiple conditions or actions using the AND/OR operator.
Multiple Conditions
You can assign multiple values to the drop-down field in both If and Then selections. For Pack and Variant Sets, select the drop-down field to select a new Pack/Variant set to add to the condition. The drop-down field automatically expands to include the new value.
Conditions within the same drop-down field will always use AND logic.
You can't assign multiple conditions to a drop-down field that contains a context. To add multiple conditions where a context is included, you must add a new If statement.
By default, a single Add (+) button is shown to the right of the light grey header with the If text. Select this button to add an empty condition block to the end of your If section. Hovering over the gap between conditions will make another plus button appear in the right column. Selecting this button will add the empty condition to the middle of the lsit instead.
To remove an If block, hover over the block and then select the X button that appears in the right column.
Multiple Actions
You can add multiple actions to a rule with. To add a new action, select the small plus button appears to the right of the header and add the correct action.
To display or hide another Variant Set or Pack Set when your Condition is True, select the Add (+) button. Then, select Set Feature Availabilities Action to identify the action and Variant Set or Pack Set.
To make it so that another Variant Set or Pack Set is automatically selected in the configurator when your Condition is true, select the Add (+) button and then Select Feature Action and select Variant or Pack Set.
The AND/OR Operator
By default, conditions in the rule engine use AND logic and are solved top to bottom with conditions in the same drop-down field or indent level being resolved as a group. Given the image below, the logic equation is as follows:
- "The Market must be set to "en" AND (Red must be selected AND the normal variant must be selected)"
You can switch to using OR logic for conditions in different dropdown fields.
Switch to OR in Forma 3.X and Below
To switch to OR logic, do the following:
- Click and hold one of your rules.
While still holding, drag your cursor toward the bottom of the rule. A row will appear between that rule and the next showing your AND connector.
Drag your cursor onto the AND button and release. A new row will appear between each rule showing an OR connector.
Unity Forma 3.X doesn't support selectively setting OR or AND logic for certain blocks. The connectors between each conditional drop-down field must either all be AND or all be OR. Conditions within the same dropdown field always use AND. To illustrate, the logic for the rule in the image above is as follows:
If Market is "en" OR (Yellow Pack AND Black Leather are available).
Switch to OR in Forma 4.0 and Above
In Forma 4.0 and above, The AND/OR block between conditions is always visible. Clicking this block will cause it to switch between AND and OR. These blocks are independent of each other and can be changed at will.
Brackets
The system solves Rule conditions from top to bottom. Conditions within brackets are always resolved first. The system treats Conditions within the same drop-down field as within a pair of brackets. You can also use indents to arrange different drop-down fields into brackets. The system treats Condition blocks that are adjacent and at the same level as within a pair of brackets.
To indent a Condition, follow these steps:
Select and hold the rule that you want to indent.
Drag your cursor to the bottom of the rule until the blue connector highlight appears.
Release the mouse. The rule will be indented.
Adjacent rules with the same indent are considered to be within a pair of brackets. For example, the logic for the image below is as follows:
If ((Yellow Pack and Black Leather are selected) OR Market is "en") OR Down Spoiler is selected.