✅ Solved: initial values for input or view model [Android]
In Android runtime, I’m trying to set initial values for data, so that I can do a check directly in my `Entry` state to send the animation directly to the correct timeline:
When I try to set inputs (or view model) before calling `play`, then the state machine does not exist yet, but if I do it right after `play`, then these values are not set as initial values, so the check in `Entry` state does not work as expected.
I was trying setting input after play
riveAnimationView.play(animationName = stateMachineName, isStateMachine = true)
riveAnimationView.setNumberState(stateMachineName, key, value.toFloat())setting input before play:
riveAnimationView.setNumberState(stateMachineName, key, value.toFloat())
riveAnimationView.play(animationName = stateMachineName, isStateMachine = true)setting view model after play:
riveAnimationView.play(animationName = stateMachineName, isStateMachine = true)
val viewModel = riveAnimationView.file?.getViewModelByName(VIEW_MODEL_NAME)
val instance = viewModel?.createBlankInstance()
instance.getNumberProperty(propertyName).value = propertyValue
riveAnimationView.controller.stateMachines.firstOrNull()?.viewModelInstance = instancesetting view model before play:
val viewModel = riveAnimationView.file?.getViewModelByName(VIEW_MODEL_NAME)
val instance = viewModel?.createBlankInstance()
instance.getNumberProperty(propertyName).value = propertyValue
riveAnimationView.controller.stateMachines.firstOrNull()?.viewModelInstance = instance
riveAnimationView.play(animationName = stateMachineName, isStateMachine = true)
neither works as expected, although setting values after `play` works if I use `Any State`… but as explained, I need to work `Entry` state