Dowload as PDF

1.3. Presets

Common Info

Presets are objects, made for creating and holding entities which controller will be working with in editor. Logic is not contained in the preset, it’s only a container for data. You can see it as parallel to this: Animator animates an object based on the data from AnimatorController, and CallbackerController tracks events and performs actions based on the data held in Presets

There are three types of presets, two of which are saved in the project as assets: Preset and PresetWrapper, as well as a common C# object, serialized “inside” controller: LocalPreset.

  • LocalPreset – is saved with the scene, can’t be used on more than one game object, doesn’t need to be saved on disk as asset. It’s useful when creating unique characters (bosses, traders, etc) or objects.
  • Preset – gives you functions analagous to LocalPreset, with the difference being that it needs to be saved on disk and can be used in several controllers. If you don’t know what type to use, use this one.
  • PresetWrapper – “wrapping” for Presets or another PresetWrapper, which lets you alter already existing entities or add new ones. To understand when to use one, lets look at an example: we have AnimatorController for a character Human with animation Jump and event, which triggers when character touches ground. But we also have OverrideAnimatorController for character Orc, and in that animation Jump is redefined, and our event doesn’t match the timing of the new animation. In this case we create PresetWrapper and change the event. Everything else remains “as in parent”.

Absolutely all presets contain data about entities, but not entities themselves. But presets also can’t be changed or created during runtime. It’s done this way with the goal of easier creation of entities from code, because classes that are correctly saved by Unity Serialization are not always comfortable to use, and vise-versa, that which is easy to use in runtime, won’t be always correctly saved into the asset/object. Because these are not entities, controller, during initialization, converts them into entities and preset is not used afterwards in any way. It’s one more reason why there’s no poing to change or create them in runtime. We can talk more about every entity in separate sections.

Editor

To edit presets, you can use intuitive and fully functional editor window, that can be called by double clicking on the asset, button in the controller inspector, or asset inspector. The window is roughly divided into five parts.

  1. Selection of the type of edited data.
  2. Preset options. Every preset type has its own. Only two buttons are common in this section: Update references and Clear preset. First button launched forced scan of all objects, that this preset is dependent on. This command is useful if some assets have changed, but editor doesn’t see the change. Second button completely clears the preset of all entities.
  3. Primary work section. In this section you can see already added and set up data in this preset, and to add/edit/delete it.
  4. Animation preview section. Some types of data have ability to choose state from AnimatorController. With the help of this window, you can see in real time that state with different speed or direction of playthrough.
  5. Section for controlling states in animation preview window. In this section we have Play button, as well as settings for speed/animation segment/current position. Also, if the previewed state is BlendTree, then all parameters used in that will be listed here.

Options of the different preset types.

  • Preset

    • Runtime Animator Controller – controller, that will be used as source of states and parameters for setting up of entities (can be used as AnimatorController as well as Override Controllers)
  • PresetWrapper

    • Use parent animator controller – defines whether Animator Controller from parent will be used. If this option is turned off, then an option to redefine link to Animator Controller will be available.
    • Runtime Animator Controller – same as above.
    • Parent preset – link to parent Preset or PresetWrapper.
  • LocalPreset

    • Source of local preset – component, containing this preset.
    • Runtime Animator ControllerAnimator Controller that is used on this GameObject.

Additionally, at the bottom of the window you can see which particular asset/object is edited at this moment, and by clicking this the ping of that asset/object will be performed.

Yes No
0 of 0 users found this section helpful
Suggest Edit