diff --git a/.rive_head b/.rive_head index 0896432..90492b7 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -c0411df0a74b2aafa18526375cda19f6779a2354 +6d9aa017961638f7576a2ea52a8928c813e28dbb diff --git a/lib/src/rive_core/animation/nested_input.dart b/lib/src/rive_core/animation/nested_input.dart index 9881abf..33fd5d3 100644 --- a/lib/src/rive_core/animation/nested_input.dart +++ b/lib/src/rive_core/animation/nested_input.dart @@ -1,6 +1,6 @@ -import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/nested_input_base.dart'; import 'package:rive/src/rive_core/animation/nested_state_machine.dart'; +import 'package:rive/src/rive_core/container_component.dart'; import 'package:rive/src/rive_core/nested_artboard.dart'; export 'package:rive/src/generated/animation/nested_input_base.dart'; @@ -20,6 +20,16 @@ abstract class NestedInput extends NestedInputBase { @override bool validate() => super.validate() && nestedStateMachine != null; + @override + void parentChanged(ContainerComponent? from, ContainerComponent? to) { + super.parentChanged(from, to); + if (nestedStateMachine != null) { + if (!nestedStateMachine!.nestedInputs.contains(this)) { + nestedStateMachine!.nestedInputs.add(this); + } + } + } + void updateValue(); @override diff --git a/lib/src/rive_core/animation/nested_state_machine.dart b/lib/src/rive_core/animation/nested_state_machine.dart index 409eaf6..150bff3 100644 --- a/lib/src/rive_core/animation/nested_state_machine.dart +++ b/lib/src/rive_core/animation/nested_state_machine.dart @@ -2,6 +2,9 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/nested_state_machine_base.dart'; +import 'package:rive/src/rive_core/animation/nested_bool.dart'; +import 'package:rive/src/rive_core/animation/nested_input.dart'; +import 'package:rive/src/rive_core/animation/nested_number.dart'; import 'package:rive/src/rive_core/nested_artboard.dart'; import 'package:rive_common/math.dart'; @@ -33,6 +36,9 @@ class NestedStateMachine extends NestedStateMachineBase { @override bool get isEnabled => _stateMachineInstance?.isActive ?? false; + final Set _nestedInputs = {}; + Set get nestedInputs => _nestedInputs; + NestedStateMachineInstance? _stateMachineInstance; NestedStateMachineInstance? get stateMachineInstance => _stateMachineInstance; set stateMachineInstance(NestedStateMachineInstance? value) { @@ -42,6 +48,12 @@ class NestedStateMachine extends NestedStateMachineBase { var from = _stateMachineInstance; _stateMachineInstance = value; stateMachineInstanceChanged(from, value); + + for (final input in nestedInputs) { + if (input is NestedBool || input is NestedNumber) { + input.updateValue(); + } + } } void stateMachineInstanceChanged(