IndieDoroid

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.
Screenshot 2021-08-27 013223.jpg


Any thoughts? :wounded: :think: :upsidedown: :'(
Nemaš dopuštenje za pregledavanje privit(a)ka dodan(og)ih postu.
Avatar
IndieDoroid
  • Postovi: 246

Harald

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?
Avatar
Harald

Harri
  • Postovi: 3907

IndieDoroid

Harald je napisao/la: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?
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; } }
Illustration.jpg


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:
Nemaš dopuštenje za pregledavanje privit(a)ka dodan(og)ih postu.
Avatar
IndieDoroid
  • Postovi: 246

Harald

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 je napisao/la: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.
This sounds as if you've solved one problem and made another one surface.
IndieDoroid je napisao/la:Am 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).
Avatar
Harald

Harri
  • Postovi: 3907

IndieDoroid

Harald je napisao/la: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.
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 je napisao/la:
IndieDoroid je napisao/la: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.
This sounds as if you've solved one problem and made another one surface.
IndieDoroid je napisao/la:Am 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:
Avatar
IndieDoroid
  • Postovi: 246

eslamZaki

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
  • Postovi: 1

Harald

@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?
Avatar
Harald

Harri
  • Postovi: 3907


Natrag na Unity