Should I dynamic Create Subtitle Panel in Run-time?

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: Should I dynamic Create Subtitle Panel in Run-time?

Post by Tony Li »

Hi,

Thanks for sharing those customizations. I'll look into incorporating them into the next Spine integration update.
bmringo
Posts: 11
Joined: Tue May 27, 2025 9:02 am

Re: Should I dynamic Create Subtitle Panel in Run-time?

Post by bmringo »

Hi,

After some work, I’ve successfully integrated Spine animations to work seamlessly with speakerportrait and listenerportrait.

Since I don’t assign the SpineObject directly to the Actor, I need the animation system to dynamically search for the correct animation by name.

In your original script SequencerCommandSpineAnimation, I updated this line:
`var animation = (references != null) ? references.animationReferenceAssets.Find(x => x.name == animationName) : null;`

Into the following two lines, separating the reference from the actual animation:
```
var animationRef = (references != null) ? references.animationReferenceAssets.Find(x => x.name == animationName) : null; // First check in reference list
var animation = (animationRef != null) ? animationRef.Animation : null;
```

Then, I modified this block:
```
if (references != null)
{
if (references.skeletonAnimation != null)
{
state = references.skeletonAnimation.AnimationState;
}
else if (references.skeletonGraphic != null)
{
state = references.skeletonGraphic.AnimationState;
}
}
```

Into this:
```
if (references != null)
{
if (references.skeletonAnimation != null)
{
if (animation == null) animation = references.skeletonAnimation.Skeleton?.Data?.FindAnimation(animationName); // Fallback to dynamic lookup from skeleton data
state = references.skeletonAnimation.AnimationState;
}
else if (references.skeletonGraphic != null)
{
if (animation == null) animation = references.skeletonGraphic.Skeleton?.Data?.FindAnimation(animationName); // Fallback to dynamic lookup from skeleton data
state = references.skeletonGraphic.AnimationState;
}
}
```
These changes are non-intrusive and only add fallback behavior, so they don’t conflict with the existing implementation.

Finally, to make everything work beautifully: as I mentioned previously, I placed the Spine Portrait next to the Portrait Image. All I had to do was assign the SpineSequencerReferences to the Portrait Image and point it to the Spine Portrait next to it. This way, each subtitle panel has its own duo: a sprite portrait and a Spine portrait.

It works perfectly. Since speakerportrait links to the Portrait Image, which already has the SpineSequencerReferences pointing to the adjacent Spine Portrait, the animation is triggered correctly.

With this setup, I can have an Actor that uses both SkeletonAnimation for the in-world model and SkeletonGraphic for the UI portrait in a single conversation. For example:

- SpineAnimation("Attack") - Actor prefabs using SkeletonAnimation.
- SpineAnimation("Hit", listener) - Actor prefabs using SkeletonAnimation.
- SpineAnimation("Smile", speakerportrait, 0, true); - Actor's Portrait using SkeletonGraphic in shared Subtitle Panel
- SpineAnimation("Sad", listenerportrait, 0, true); - Actor's Portrait using SkeletonGraphic in shared Subtitle Panel

Hope this gives you some ideas for improving Spine support in future updates.
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: Should I dynamic Create Subtitle Panel in Run-time?

Post by Tony Li »

Hi,

Thank you again! I'll take this into account when updating the Spine integration for the next release.
Post Reply