- Изменено
SkeletonGraphic的Equip问题
我在Spine-Unity 3.8中学习了Demo “Mix and Match Equip”的功能。请问一下,Mix and Match Equip的功能如何应用于SkeletonGraphic ?我尝试后发现替换的attachment是错误的。
我希望在游戏的Inventory中为Character装备武器,并且在Unity UI中显示装备后的效果。可以给我一个有关的Demo吗?
不胜感谢。
通常,您可以在SkeletonGraphic.Skeleton
上调用与SkeletonAnimation.Skeleton
相同的方法。
In general, you can call the same methods on SkeletonGraphic.Skeleton
as on SkeletonAnimation.Skeleton
.
但是,由于SkeletonGraphic具有单一材质的限制,因此您需要确保生成组合皮肤,以便所有内容最终都位于单个图集页面中。 在按下“完成”按钮时,您可以看到如何在“混合和匹配装备”示例中生成组合皮肤:
spine-runtimes/EquipSystemExample.cs at 3.8
spine-runtimes/EquipsVisualsComponentExample.cs at 3.8
However, since SkeletonGraphic has the limitation of a single material, you need to be sure to generate the combined skin, so that everything ends up in a single atlas page. You can see how to generate the combined skin in the Mix and Match Equip
example when pressing the Done
button:
spine-runtimes/EquipSystemExample.cs at 3.8
spine-runtimes/EquipsVisualsComponentExample.cs at 3.8
或者你面临着不同的问题?
Or are you facing a different problem?
Hi Harald , 非常感谢您的回答,我在生成组合皮肤时,加入了如下代码:
skeletonGraphic.OverrideTexture = runtimeAtlas;
现在我之前的疑问已经解决了,但是新的问题出现了,我在换肤(change Skins)的时候局部的图片出现了错误。
在SkeletonAnimation中是这样: Изображение удалено из-за отсутствия поддержки HTTPS. | Показать Изображение удалено из-за отсутствия поддержки HTTPS. | Показать
After changing skin
但在SkeletonGraphic中是这样: Изображение удалено из-за отсутствия поддержки HTTPS. | Показать Изображение удалено из-за отсутствия поддержки HTTPS. | Показать
After changing skin
你可以看到在SkeletonGraphic中右边的腿部变黑了,请问这是什么原因?
很高兴听到它有所帮助。
Glad to hear that it helped.
既然你提到过:
skeletonGraphic.OverrideTexture = runtimeAtlas;
切换皮肤不能像调用以下方法那样工作吗?
skeletonGraphic.Skeleton.Skin = repackedSkin;
或者你为什么使用skeletonGraphic.OverrideTexture
?
如果有必要,您确定runtimeAtlas
是否与新的组合皮肤图集页面的更改保持同步?
Since you mentioned calling:
skeletonGraphic.OverrideTexture = runtimeAtlas;
Did switching skins not work like when calling the following method?
skeletonGraphic.Skeleton.Skin = repackedSkin;
Or why are you using skeletonGraphic.OverrideTexture
?
If it was necessary, are you sure that runtimeAtlas
is up to date with the changes from the new combined skin atlas page?
感谢您的积极回复。
请看下我的代码,我只拿SkeletonAnimation举例,因为情况很类似。
protected string _equipsSkinName;
Spine.Skin equipsSkin;
public void StartEquipsSkin (string skinName)
{
_equipsSkinName = skinName;
equipsSkin = skeletonAnimation.Skeleton.Data.FindSkin(_equipsSkinName);
skeletonAnimation.Skeleton.SetSkin(equipsSkin);
RefreshSkeletonAttachments();
OptimizeSkin();
}
public void OptimizeSkin()
{
collectedSkin = new Skin("Collected skin");
collectedSkin.Clear();
collectedSkin.AddAttachments(skeletonGraphic.Skeleton.Data.DefaultSkin);
collectedSkin.AddAttachments(equipsSkin);
var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin",
skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
collectedSkin.Clear();
skeletonAnimation.Skeleton.SetSkin(repackedSkin);
RefreshSkeletonAttachments();
}
void RefreshSkeletonAttachments ()
{
skeletonAnimation.Skeleton.SetSlotsToSetupPose();
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton); //skeletonAnimation.Update(0);
}
如果在StartEquipsSkin (string skinName)中不去执行OptimizeSkin(),那么皮肤切换正常。 Изображение удалено из-за отсутствия поддержки HTTPS. | Показать
但如果像上面的代码那样去执行OptimizeSkin(),皮肤切换就会出问题。 Изображение удалено из-за отсутствия поддержки HTTPS. | Показать
您可以告诉我是哪里出错了吗?
对不起,我认为这个问题只发生在SkeletonGraphic
上,并且一切都与SkeletonAnimation
配合得很好。
Sorry, I thought that the problem only occurred with SkeletonGraphic
and everything worked well with SkeletonAnimation
.
代码看起来正确,看起来好像存在导致错误映射的错误。 你能给我们发一个最小的Unity项目的zip文件来演示这个问题吗? 如果您也可以向我们发送Spine项目,那将会更有帮助。 您可以将其发送至 contact@esotericsoftware.com. 然后我们可以看看它。
谢谢!
The code looks correct, it seems as if there is a bug that causes incorrect mapping. Could you please send us a zip file of a minimal Unity project that demonstrates this problem? If you could also send us the Spine project, that would help even more. You can send it to contact@esotericsoftware.com. Then we can have a look at it. Thank you!
Hi, Harald, 我刚刚给您发了一封邮件,邮箱的地址是
nozwang@gmail.com
邮件内有一个Unity project的zip文件,还有一个Spine project文件。请您查收。有任何问题,请随时联系我,留言或者回复邮件都可以。再次感谢!
感谢您的电子邮件和非常清晰的复制项目! 我现在可以很好地重现这个问题。 一旦我们发现出了什么问题,我们会尽快回复您。
Thank you for your email and the very clear reproduction project! I can now reproduce the problem very well. We will get back to you as soon as we have found out what is going wrong.
问题现已解决,您可以从这里下载最新的unitypackages:
Spine Unity Download
The problem is now fixed, you can download the latest unitypackages from here:
Spine Unity Download
非常感谢您通过非常好的复制项目报告此问题!
Thanks very much for reporting this problem with a very clear reproduction project!
Hi,Harald,感谢回复,我又给您发了一封邮件,我更新了最新的unitypackages,并且放到我的reproduction project中,但是当我更换皮肤的时候,好像Attachments发生了错位,您可以在我的reproduction project中实验一下,如果您那边是正常的,请告诉我哪里出了问题,再次感谢。
谢谢,我收到了你的电子邮件。 一旦我弄清楚出了什么问题,我会看一看会回复你的。
Thanks, I received your email. I will have a look an will get back to you as soon as I have figured out what went wrong.
嗨Waylon。 我记得很清楚,你在之前的错误报告中提供了一个很好的复制包,并且一直非常有礼貌!
很抱歉您再次遇到问题!
Hi Waylon. I remember you well, you have provided a good reproduction package at the previous bug report and have always been very polite!
We are sorry that you are facing problems again!
至少着色器似乎不是问题(或者至少它包括在内并且是活动的),因为我看到添加混合模式是活动的。 我想知道纹理是白色/缺失,还是UV坐标是错误的。
At least the shader seems not to be the problem (or at least it is included and active), since I see additive blend mode being active. I wonder if the textures are white / missing, or if the UV coordinates are wrong.
如果仅在使用IL2CPP为Mac构建时出现此问题,您是否尝试过? 在将脚本后端设置为“mono”而不是IL2CPP的情况下定位其他平台或构建时,是否也会出现此问题?
Have you tried if this problem only occurs when building for Mac with IL2CPP? Does This problem also occur when targeting other platforms or building with scripting backend set to mono
instead of IL2CPP?
很高兴您听说这只是配置问题。 感谢分享!
Glad you hear that it was only configuration problems. Thanks for sharing!