mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-30 02:03:07 +08:00
56 lines
2.6 KiB
Markdown
56 lines
2.6 KiB
Markdown
|
---
|
||
|
sidebar_position: 1
|
||
|
---
|
||
|
|
||
|
# Reactive Components
|
||
|
|
||
|
Reactive Components are components which apply some effect to your avatar based on the active state of their GameObject
|
||
|
(and its parents), or [Menu Item](../menu-item.md) enabled states. This allows you to build up simple toggles, adjust
|
||
|
blendshapes as you change your outfit, and more - without needing to manually set up any animations.
|
||
|
|
||
|
The following reactive components are currently available:
|
||
|
|
||
|
* [Object Toggle](./object-toggle.md) - controls the active state of other game objects
|
||
|
* [Shape Changer](./shape-changer.md) - modifies blendshapes on a target renderer
|
||
|
|
||
|
## General rules for reactive components
|
||
|
|
||
|
In general, reactive components apply some kind of effect when they are _active_. A reactive component is considered
|
||
|
active when:
|
||
|
|
||
|
- Its GameObject, and all parents, is active in the scene hierarchy.
|
||
|
- If the reactive object is on the same GameObject as a [Menu Item](../menu-item.md), the Menu Item is selected.
|
||
|
|
||
|
After building your avatar, reactive components respond to the following:
|
||
|
|
||
|
- Animations which change the state of GameObjects
|
||
|
- Object Toggles which influence the active state of other reactive components
|
||
|
- Menu Item selections
|
||
|
|
||
|
### Priority rules
|
||
|
|
||
|
If multiple reactive components are active at the same time, and their effects conflict (e.g., one tries to turn off a
|
||
|
game object, one tries to turn on a game object), the component lowest in the hierarchy takes precedence.
|
||
|
|
||
|
### Reaction timing
|
||
|
|
||
|
Reactive components responding to the change of a GameObject's active state will do so after a one frame delay. When the
|
||
|
game object is being deactivated, the game object's deactivation will be delayed by one frame to happen at the same
|
||
|
time.
|
||
|
See [Shape Changer](./shape-changer.md) for more information on why this is the case.
|
||
|
|
||
|
If one reactive component controls the state of another reactive component, then there will be a one frame delay between
|
||
|
each reactive component triggering. The delay will be applied to each reactive component individually, so if you have
|
||
|
A -> B -> C, and A is turned off, the timing will be as follows:
|
||
|
|
||
|
* Frame 1: Nothing happens (A's disable is delayed)
|
||
|
* Frame 2: A is disabled (B's disable is delayed)
|
||
|
* Frame 3: B and C are disabled at the same time.
|
||
|
|
||
|
### Preview system
|
||
|
|
||
|
The effect of reactive components on mesh visibility is immediately reflected in the editor scene view. However, this
|
||
|
has some limitations; in particular, it considers the current active state of objects, and the "default" state of Menu
|
||
|
Items, but does not consider the effect of Object Toggles on other reactive components. To see the full effect of
|
||
|
reactive
|
||
|
components, you must enter play mode.
|