Give Page Feedback

Scriptable Assets - Assignment Selector

The Assignment Selector offers you a way to write custom logic for choosing how game objects are selected during the World Designer Tool's Assignment Operation. This allows you to introduce new selection criteria or to combine one or more techniques for more complex selection logic.

Creating Assignment Selector Classes

There are no default Assignment Selector classes included with SAM, as most of the default selection techniques are already covered with the existing What To Assign options on the World Designer Tool. As such, in order to use the Assignment Selector, you must create your own custom class that derives from the base abstract AssignmentSelector class.

In order to interface with the AssignmentSelector class, you must create the script in a folder called Editor and you should place the class definition inside of the DeepSpaceLabs.EditorSAM namespace.

In your custom class, you must simply provide an override for the IsMatch method (let your IDE complete the method signatures to make things easier).

Creating logic inside of this method should be fairly straightforward. The method takes as an argument a Transform, which is associated with the game object you should check. If you want the game object to be selected for the current Assignment Operation, you should return true, otherwise you should return false.

In addition to this, you can optionally override the OnAssignmentStarting method as well. This method is called once prior to each Assignment Operation, and is passed the World, index of the World Grouping and LOD Group that any selected objects will be assigned to for the current Operation.

This method is incredibly powerful, as it allows you to configure the Selector to work differently for each World, Grouping, and/or LOD Group that the Selector is used with. This not only reduces the number of unique Selector assets you need to create, it also eliminates the need to change out the Selector that is being used as you perform Assignment Operations for differenet Groupings and LOD Groups!

Creating Assignment Selector Assets

Assignment Selectors are Scriptable Assets, so in order to use them, you must create the physical scriptable object asset in your project hierarchy. To do this, you can place the following line of code above your class definition (Replacing SampleAssignmentSelector and Sample Assignment Selector with your own names):

[CreateAssetMenu(fileName = "SampleAssignmentSelector", menuName = "Deep Space Labs/SAM/Assignment Selectors/Sample Assignment Selector")]

Once you add this line of code, you will be able to create the phsyical asset by right clicking a folder in your project hierarchy and using the Create asset menu.

Using Assignment Selector Assets

Assignment Selectors can be assigned to the World Designer Tool by first selecting Custom Assignment Selector for the What To Assign option (via the Editing Controls tab of the Main Controls window of the World Designer Tool).

Once you select Custom Assignment Selector, you will see a new Assignment Selector field where you can assign the Selector asset you've created.

Note that the Assignment Selector you choose will be used for all Assignment Operations. If you need custom logic for different Groupings and/or LOD Groups (for example, perhaps some groupings should be assigned game objects with a specific tag, while others use a different tag), you will either need to write such logic into your Assignment Selector class, or create multiple Selector assets and switch them out depending on which Grouping and/or LOD Group you are assigning to.

Limitations

Each Assignment Operation always assigns objects to a single LOD Group on a single World Grouping. The use of a custom Assignment Selector cannot get around this!