- Uređeno
skeletonGraphic not animating
Hi guys,
Spine 3.8.99
I'm at a loss. I thought I fixed it last year, but this keeps popping up.
I'm getting inconsistent behavior from the Skeleton Graphic animation. I'm using it in my UI canvas. The animations sometimes plays and sometimes won't, just freezing at the "T Pose" that was set in Spine.
I'm freezing time with
Time.timeScale = 0;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
This is how I'm playing the animation once the UI is enabled.
[SerializeField] private SkeletonGraphic _skeletonGraphic;
[SerializeField] private enum Expression { Idle }
[SerializeField] private Expression _expressionEnum;
Void GetArt()
{
if (_skeletonGraphic.IsValid)
{
_skeletonGraphic.Skeleton.SetSkin("Classic");
_skeletonGraphic.Skeleton.SetSlotsToSetupPose();
_skeletonGraphic.AnimationState.SetAnimation(0, Expression.Idle.ToString(), true);
_skeletonGraphic.Update(0);
}
}
These are the settings. I tried toggling the "Update when invisible" to always animate.. still same issues.
Any thoughts? :wounded: :think: :upsidedown:
Sorry to hear you're facing troubles. I'm afraid the posted code will not be sufficient to help, as we do not know from where you are calling the Void GetArt()
method. BTW: Did you introduce an alias for void
with an uppercase-V, or did you just paste pseudo-code here?
Also, are the GameObjects active from the beginning, are they a fixed part of a scene or instantiated?
Harald wroteSorry to hear you're facing troubles. I'm afraid the posted code will not be sufficient to help, as we do not know from where you are calling the
Void GetArt()
method. BTW: Did you introduce an alias forvoid
with an uppercase-V, or did you just paste pseudo-code here?Also, are the GameObjects active from the beginning, are they a fixed part of a scene or instantiated?
Hi Harald
sorry for the delay. finally got around to trying to fix this again. It's more or less the code, but cleaned up the variable names so it's easier to read.
GetArt()
is called in Update() when the canvas is enabled. So the canvas check is
void Update ()
{
if (_player.GetButtonDown(StatsPage))
{
if (canvas.enabled)
{
GetArt();
}
}
}
I just noticed .. I cannot get validation on:
if (_skeletonGraphic.IsValid)
When I do a ...
print(_skeletonGraphic.IsValid)
... I get a return of FALSE.
So when I dug in a bit deeper into the code I found Spine was looking for Skeleton
protected Skeleton skeleton;
public Skeleton Skeleton {
get {
Initialize(false);
return skeleton;
}
set {
skeleton = value;
}
}
public SkeletonData SkeletonData { get { return skeleton == null ? null : skeleton.data; } }
public bool IsValid { get { return skeleton != null; } }
Am I missing something here? Is the SkeletonDataAsset supposed to be the SkeletonData?
I've commented out these lines and the animations are playing again.. but inconsistently.. still the animation is stuck at the T Pose certain times. :think:
//if (_skeletonGraphic.IsValid)
{
_skeletonGraphic.Skeleton.SetSkin("Classic");
//_skeletonGraphic.Skeleton.SetSlotsToSetupPose();
_skeletonGraphic.AnimationState.SetAnimation(0, Expression.Idle.ToString(), true);
//_skeletonGraphic.Update(0);
}
Thanks for your help :wounded:
In general skeleton.Initialize()
needs to be called before setting animations or similar. In spine-unity 3.8 (and 4.0) skeletonGraphic.Skeleton
as well as skeletonGraphic.AnimationState
will implicitly call Initialize()
. So you should actually remove the call to if (_skeletonGraphic.IsValid)
unless you have reasons for it.
IndieDoroid wroteI've commented out these lines and the animations are playing again.. but inconsistently.. still the animation is stuck at the T Pose certain times.
This sounds as if you've solved one problem and made another one surface.
IndieDoroid wroteAm I missing something here? Is the SkeletonDataAsset supposed to be the SkeletonData?
The SkeletonData Asset
property in the Inspector should be set to the asset with suffix _SkeletonData
that is generated upon import (next to your .json
or .skel.bytes
file).
Harald wroteIn general
skeleton.Initialize()
needs to be called before setting animations or similar. In spine-unity 3.8 (and 4.0)skeletonGraphic.Skeleton
as well asskeletonGraphic.AnimationState
will implicitly callInitialize()
. So you should actually remove the call toif (_skeletonGraphic.IsValid)
unless you have reasons for it.
Ok thanks for letting me know. The isValid check was from one of the other Spine threads. I think Nate suggested it. But this was a thread from a while back, so it sounds like the check is unnecessary now.
Harald wroteIndieDoroid wroteI've commented out these lines and the animations are playing again.. but inconsistently.. still the animation is stuck at the T Pose certain times.
This sounds as if you've solved one problem and made another one surface.
IndieDoroid wroteAm I missing something here? Is the SkeletonDataAsset supposed to be the SkeletonData?
The
SkeletonData Asset
property in the Inspector should be set to the asset with suffix_SkeletonData
that is generated upon import (next to your.json
or.skel.bytes
file).
Hmm ok looks like I need to try this out on an empty project. That'll help narrow down exactly where I'm messing up. I'll keep you posted. Thanks :detective:
Hello i have the same problem
that i have 7 animations in UI skeletonGraphic and want to play them with buttons but they are acting like overwrite on each other is there any solution thanks :wounded: :wounded:
@eslamZaki Could you please describe in more detail what your exact problem is? Please describe what your code and component logic looks like, what you are expecting to be happening and what you see instead?