Hi, I'm a beginner at Unity and Spine runtime. I am currently trying to make a android live wallpaper app with spine. When the user clicks the spine object, the character will play an audio. I've modified uLipSync's code to find out which phoneme is playing, and I want to change the mouth's size base on that. How can I change the mouth's size (X and Y) in script?
Resize Mesh Size at Script
- 수정됨
HyperBlaze While we don't know the setup of your skeleton, likely you just need to change the X and Y scale of your mouth bone. The easiest way to modify the scale via a SkeletonUtilityBone
in mode Override
, see the documentation below:
https://esotericsoftware.com/spine-unity#SkeletonUtilityBone
@HyperBlaze Another way which requires a few more lines of code would be to set the bone scale directly via code, as described in this section:
https://esotericsoftware.com/spine-unity#Getting-and-Setting-Bone-Transforms-Manually
If you don't set the bone scale via any of the running animations, you can simply modify the local scale of the bone via e.g. the following code:
[SpineBone] public string mouthBoneName = "";
protected Bone mouthBone;
void Awake () {
mouthBone = skeletonAnimation.Skeleton.FindBone(mouthBoneName);
}
void Update() {
mouthBone.ScaleX =..;
mouthBone.ScaleY =..;
}
Harald Found out that using ScaleX, Y doesn't quite work even after changing the bone mode to "Override". But, the mouth Image seems to respect the size of the Scale inside of Transform when the bone is "Override".
It would be easy to scale from the script from now on.
HyperBlaze Found out that using ScaleX, Y doesn't quite work even after changing the bone mode to "Override"
You either use SkeletUtilityBone
and change Transform scale, or directly set bone.ScaleX
, not both. Don't create a SkeletonUtilityBone
hierarchy if you're setting bone.ScaleX
. Sorry if my above description was confusing.
Just note that setting the local bone.ScaleX
might not have any effect when a playing animation also keys Scale X, overriding your previously set Scale X value when applying the animation. You can use the SkeletonAnimation.UpdateLocal
callback delegate to call your method which sets Scale X at the right time after the animation has been applied. This is also explained here in the documentation.