Hello, i'm trying to play the animation on a scene, while we are on editor mode. is this possible ?
The little "preview " windows on the inspector is not enough for me. (for various reason)
Page 1 of 1
Wonse
4 years ago
-
Wonse - Posts: 16
Harald
Sorry to have missed your post. Do you mean to have a preview of animation frames in the scene view while not in play mode? I see your point, but what frame of an animation would you like to see previewed in the scene view, or would you expect to have a control-panel to select frames of an animation? Then you could still not easily test any transitions. Overall it seems to work a bit against the way Unity is designed.
I would either recommend
a) to drag the borders of the inspector window larger, then the preview window can get quite large - you can also preview transitions this way, or
b) to enter play-mode to see animations with all transitions as they are appearing.
If you have a better idea how things should be previewed in the editor, please let us know.
I would either recommend
a) to drag the borders of the inspector window larger, then the preview window can get quite large - you can also preview transitions this way, or
b) to enter play-mode to see animations with all transitions as they are appearing.
If you have a better idea how things should be previewed in the editor, please let us know.
4 years ago
-
Harald - Posts: 4459
Pharan
Harald, he's talking about in Unity.
Currently, we don't have animation preview in scene view in Unity.
But it could be added. We'll look into how it might be done, 'cause we don't actually use Unity's own windows. We would have to come up with a new interface for it.
Currently, we don't have animation preview in scene view in Unity.
But it could be added. We'll look into how it might be done, 'cause we don't actually use Unity's own windows. We would have to come up with a new interface for it.
Spine-Unity Docs Repo, and check out the Unofficial Spine Users Tumblr.
4 years ago
-
Pharan - Posts: 5366
Wonse
Yas i was talking about unity. thanks for your answers
4 years ago
-
Wonse - Posts: 16
kaarloew
We would also like to have this feature. This would be extremely useful when positioning UI related Spines that have animations. In our case option to show first and/or last frame of selected animation would be enough.
3.5 years ago
- kaarloew
- Posts: 20
Harald
We have the feature listed on our roadmap.
You can subscribe to the issue ticket here to receive notifications upon any updates:
[unity] Arbitrary frame animation preview in Scene · #1304
You can subscribe to the issue ticket here to receive notifications upon any updates:
[unity] Arbitrary frame animation preview in Scene · #1304
3.5 years ago
-
Harald - Posts: 4459
WiseKodama
using Spine.Unity;
using UnityEngine;
using Sirenix.OdinInspector;
[ExecuteInEditMode]
public class SpineAnimationScrubber : MonoBehaviour
{
[ShowInInspector]
private SkeletonAnimation skeletonAnimation;
[ShowInInspector]
[SpineAnimation]
public string animationName;
private float previousTime = 0.0f;
private float maxRange = 1.0f;
[ShowInInspector, PropertyRange(0.0, 1.0f, MaxMember = "@maxRange")]
private float currentTime = 0.0f;
private string previousAnimationName;
private Spine.TrackEntry anim;
private void OnValidate()
{
if( skeletonAnimation == null )
{
skeletonAnimation = GetComponent<SkeletonAnimation>();
}
if( skeletonAnimation == null ) return;
if( animationName != previousAnimationName )
{
anim = skeletonAnimation.AnimationState.SetAnimation(0, animationName, false);
maxRange = anim.Animation.Duration * 0.5f;
currentTime = 0.0f;
previousTime = -1.0f;
previousAnimationName = animationName;
} else if( anim == null && !string.IsNullOrEmpty( animationName ) )
{
anim = skeletonAnimation.AnimationState.SetAnimation( 0, animationName, false );
}
if( anim != null && currentTime != previousTime )
{
if( skeletonAnimation.state == null ) return;
anim.TrackTime = currentTime;
skeletonAnimation.Update( currentTime );
skeletonAnimation.state.Update( currentTime );
skeletonAnimation.LateUpdate();
skeletonAnimation.skeleton.Update(currentTime);
previousTime = currentTime;
}
}
}
I just needed something like this, so I made a simple animation scrubber. Could easily just update the current time OnInspectorGUI if you make custom inspector for it, but I had no need for that part. using UnityEngine;
using Sirenix.OdinInspector;
[ExecuteInEditMode]
public class SpineAnimationScrubber : MonoBehaviour
{
[ShowInInspector]
private SkeletonAnimation skeletonAnimation;
[ShowInInspector]
[SpineAnimation]
public string animationName;
private float previousTime = 0.0f;
private float maxRange = 1.0f;
[ShowInInspector, PropertyRange(0.0, 1.0f, MaxMember = "@maxRange")]
private float currentTime = 0.0f;
private string previousAnimationName;
private Spine.TrackEntry anim;
private void OnValidate()
{
if( skeletonAnimation == null )
{
skeletonAnimation = GetComponent<SkeletonAnimation>();
}
if( skeletonAnimation == null ) return;
if( animationName != previousAnimationName )
{
anim = skeletonAnimation.AnimationState.SetAnimation(0, animationName, false);
maxRange = anim.Animation.Duration * 0.5f;
currentTime = 0.0f;
previousTime = -1.0f;
previousAnimationName = animationName;
} else if( anim == null && !string.IsNullOrEmpty( animationName ) )
{
anim = skeletonAnimation.AnimationState.SetAnimation( 0, animationName, false );
}
if( anim != null && currentTime != previousTime )
{
if( skeletonAnimation.state == null ) return;
anim.TrackTime = currentTime;
skeletonAnimation.Update( currentTime );
skeletonAnimation.state.Update( currentTime );
skeletonAnimation.LateUpdate();
skeletonAnimation.skeleton.Update(currentTime);
previousTime = currentTime;
}
}
}
I am sure the code can be optimized, but I didn't bother tbh.
Note: I am using OdinInspector for the PropertyRange attribute, but you can achieve the same dynamic range with a custom inspector.
Let me know if it helps

3 months ago
- WiseKodama
- Posts: 11
Harald
Thanks for sharing your code, always much appreciated! 

3 months ago
-
Harald - Posts: 4459
leese
Thank you!
2 months ago
- leese
- Posts: 1
Mark topic unread
• Page 1 of 1
Return to Unity
- All times are UTC