As the title shows, I need to render spine resources with Unity's canvasRender, and at the same time, I need to use Unity's Animtor and OverrideAnimatorController to control Spine characters with the same animation behavior. Unfortunately, SkeletonGraphic component and SkeletonMecanim component cannot be shared. So, is there any way to meet my needs?
render with unityUI and use unity animtor to control the spine animation
@ECG_Kinsey We're sorry for the inconvenience! Currently you need to use a wrapper that forwards Mecanim state changes to SkeletonGraphic
as shown in the example scene
Spine Examples/Other Examples/StateMachine SkeletonAnimation/Mecanim Logic SkeletonAnimation View
that comes with the spine-unity unitypackage. The example scene demonstrates driving a SkeletonAnimation
component from a Mecanim controller, but it should be easy to modify to target SkeletonGraphic
instead of SkeletonAnimation
since it also contains the same Skeleton
and AnimationState
properties.
Harald Thank you for your reply. I can try it as you said
Will there be official support for this demand in the future?
@ECG_Kinsey Yes, definitely.
Long answer: It's already part of unreleased restructured code where the animation and visualisation are then two separate components. It's part of this issue ticket here:
EsotericSoftware/spine-runtimes1414
Unfortunately it will still take quite some time until we get to finalize the implementation, as the restructured runtime needs to satisfy many requirements at once and this big breaking change with automatic project migration shall only be made once (and not change soon thereafter).
Harald The methods in the example scene
Spine Examples/Other Examples/StateMachine SkeletonAnimation/Mecanim Logic SkeletonAnimation View
satisfy only simple management of animation state. Each animation and animation transition in the unity Animation state machine requires a wrapper to serialize the binding relationship with the animation in SkeletonAnimation, which is not good for long-term maintenance projects. Also, this method doesn't do the automatic blending transitions of the skeleton animations in the animation state machine. What we need more is a script similar to SkeletonMecanim that matches the unity animation state machine and the Spine animation well. But the SkeletonMecanim script and the SkeletonGraphic script cannot run at the same time.
@ECG_Kinsey I'm afraid there is no better solution available currently for using Mecanim with a CanvasRenderer
(or with SkeletonGraphic
) currently. We would then recommend using the AnimationState
API of SkeletonGraphic
instead if you need the full feature set with a CanvasRenderer
.
The only alterantive I can suggest is creating a variant of SkeletonMecanim
which uses the visualisation (mesh-generation) code of SkeletonGraphic
.
Harald Yes, I have implemented this function through a variant of SkeletonMecanim,
and it seems to work well at present, but I am not sure if there are potential problems, and hope to have official support in the future, because this is a very regular requirement