Hey Guys, this blog is part of a series "Skeleton Animation in Unity" . In this i'll try to explain "What are Stateful and Stateless classes in Spine Unity".
The whole unity spine classes are divided into Stateful and Stateless data classes.
Stateful Classes: Objects of these classes can be modified without affecting other instances.
Like Bone repositioning, changing the time scale of an animation state or we can flip skeleton object in X or Y axis, while doing these kind of things it will apply only single instance.
Example:
- skeletonAnimation.timeScale =2;
- skeletonAnimation.skeleton.flipX=true;
- skeletonAnimation.skeleton.flipY=true;
Stateless Classes: Changes in these classes always affect all Skeleton instances we create. Such as SkeletonData, Animation, Attachment, BoneData, SlotData. Objects defined by these classes are shared commonly by design that is the reason for it to affect all the instances since Spine Unity Spine GameObject creates one Skeleton.
Stateless objects are not required to modify most of the time.
Example :
- SkeletonBone bone = new SkeletonBone (); bone.scale = 2;
- Slot *slot = Skeleton_findSlot(mySkeleton, "head");
NOTE:
While using Stateful objects, we always access them through Skeleton. Like when we have to set an animation pose or swap slot attachment.
While using Stateless objects, we always access them through SkeletonData. Like when we information about like its duration, event, set/bind pose.
Comment for suggestions
Thank You !
1 Comment(s)