What is the Rule Engine ?

The Rule Engine is a feature introduced in since the Pixyz Plugin  for Unity 2018.3.

It is part of the optimization and staging tools available in this plugin.

The Rule Engine comes with out of the box with features giving the ability to optimize or stage your scene in an automatic way. Unlike the Toolbox, the Rule Engine actions are applied sequentially. This allows one-click importing, optimizing and staging, which can be a very handy tool when importing multiple similar files requiring the same kind of processing, or for working in realtime between your modeling application and Unity thanks to the Live Sync.

The Rule Engine isn't restricted to Pixyz-imported models ; it can work on anything in your scene.

The Rule Engine has a set of Default Rule Engine Actions that contains common tools for optimizing / staging your scene. Some of them are directly using Pixyz native Core algorithms.

Some actions will act as filters and will simply modify your selection, but some other, such as Merge, Decimate or Create Uvs for example will modify the asset itself.

How to use the Rule Engine ?

The Rule Engine works with serialized sets of rules, so, first of all, a set of rules needs to be created.

  • In the project folder, do a right click and click Create > Pixyz > RuleEngine Rules

  • Click on the created set of rule (by default called "New Rules") and click + in the inspector to add a rule to that set

  • Add a starting point. For example, by using Latest Imported Model as your starting point, you know that the next block will operate on the latest model you have imported with Pixyz. This is generally the starting point you want to use if you want to use this rule after importing or with the Live Sync.

  • Then add your own logic. Filters, actions, .... You can also add more Rules. The rules are applied sequentially, from top to bottom.

  • When your set of rules is done, you can either execute it directly by clicking Run (for example if you want to test it), or you can link it in the Import Window or in Live Sync.

WARNING        Rule Engine actions can't be undone

WARNING        The Rule Engine is only available in the Unity Editor

Extending the Rule Engine

If the Default Rule Engine Actions doesn't offer what you need, you can implement you own Rule Engine actions. Benefits are the simplicity & convenience, and the fact that it can also be used in the Toolbox.

To proceed, simply click Pixyz  > RuleEngine > Create New Custom Action

A new script will be created in your project. This script is by default named "NewCustomActions.cs" and it always placed in an Editor folder.

For more information on how to implement your Action logic, please read Creating a Custom Action from the Scripting Documentation.