• 中文
  • skeletonDataAsset == null

  • Изменено
Related Discussions
...

在unity editor中运行(在apk中运行也偶尔会发生),有时候scene中的skeleton,突然发生skeletonDataAsset丢失的情况。
具体表现就是运行后,发生下面的错误。

error !!! : skeleton asset isn't exist! *******
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
Spine.Unity.SkeletonGraphic:Initialize (bool) (at Assets/ThirdPart/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs:505)
Spine.Unity.SkeletonGraphic:Awake () (at Assets/ThirdPart/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs:217)

下面是相关代码。
public void Initialize (bool overwrite) {
if (this.IsValid && !overwrite) return;

if (this.skeletonDataAsset == null)
{
Debug.LogError("error !!! : skeleton asset isn't exist! " + gameObject.name);
return;
}

并不是每次运行都会出现,而是大约几十次会出现一次。


这样使用的。


如果不能找到原因,能够给一些定位问题的建议,也非常感谢。

很抱歉听到您遇到问题!
我们过去曾解决过类似的问题。 您使用的是哪个版本的 spin-unity 运行时(unitypackage 的名称,也在 Assets/Spine/version.txt 中列出)?


Sorry to hear you're having troubles!
We have resolved a similar issue in the past. Which version of the spine-unity runtime (name of the unitypackage, also listed in Assets/Spine/version.txt) are you using?

This Spine-Unity runtime works with data exported from Spine Editor version: 3.8.xx
Package version: spine-unity-3.8-2021-11-10.unitypackage

谢谢(你的)信息。虽然 3.8 版本比我想的错误修正要旧一点,但 SkeletonGraphic 应该已经在您的 3.8 版本的 spin-unity 运行时中进行了所有空检查。

您是否使用任何延迟加载机制,例如资产包、资源、可寻址等?

问题可能只发生在预制件上,还是也发生在普通游戏对象上?有问题的骨架游戏对象是场景的一部分,还是在运行时以不同方式添加(作为预制件、通过代码等)?

你提到它有时也会发生在构建的 .apk 包中:在构建一个包之后,每次运行相同的构建包时,它是否会失败,并且每次运行相同的构建包时都会失败,并且在每 N 个构建之后(因此设置失败)在建造期间)?或者有时单个构建会失败(因此失败在运行时是随机的)?

您是否有任何活动脚本可以修改“SkeletonGraphic”作为预构建步骤,或者在运行时启动时修改它?

您能否向我们发送一个仍然演示此问题的最小 Unity 项目?您可以将其作为 zip 包发送至 contact@esotericsoftware.com,并简要提及此论坛主题 URL,以便我们了解上下文。然后我们可以看看它。


Thanks for the info. While version 3.8 is a bit older than the bugfix I was thinking of, SkeletonGraphic should already have all null-checks in place in your 3.8 version of the spine-unity runtime.

Are you using any delayed-loading mechanisms such as asset bundles, resources, addressabled or the like?

Is the problem perhaps only occurring at prefabs, or on normal GameObjects as well? Is the problematic skeleton GameObject part of a scene, or is it added differently at runtime (as a prefab, via code, etc.)?

You mentioned that it sometimes happens with the built .apk package as well: after one package is built, is it then failing with skeletonDataAsset being null every time you run the same build package, and after every N builds (so failure is set during built-time)? Or does a single build fail sometimes (so failure is random at runtime)?

Do you perhaps have any scripts active that modify the SkeletonGraphic either as a pre-build step, or modify it at startup during runtime?

Could you perhaps send us a minimal Unity project that still demonstrates this problem? You can send it as a zip package to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at it.

您是否使用任何延迟加载机制,例如资产包、资源、可寻址等?
answer: no

问题可能只发生在预制件上,还是也发生在普通游戏对象上?有问题的骨架游戏对象是场景的一部分,还是在运行时以不同方式添加(作为预制件、通过代码等)?
answer: 有问题的骨架游戏对象是场景的一部分

你提到它有时也会发生在构建的 .apk 包中:在构建一个包之后,每次运行相同的构建包时,它是否会失败,并且每次运行相同的构建包时都会失败,并且在每 N 个构建之后(因此设置失败)在建造期间)?或者有时单个构建会失败(因此失败在运行时是随机的)?
answer: 失败在运行时是随机的,概率大约 2%.

您是否有任何活动脚本可以修改“SkeletonGraphic”作为预构建步骤,或者在运行时启动时修改它?
answer: 没有任何修改。

您能否向我们发送一个仍然演示此问题的最小 Unity 项目?您可以将其作为 zip 包发送至
answer: 演示程序无法重现。游戏中一共大约100个spine动画, 但只有两三个动画偶尔会发现出现这种问题,概率太小,没有办法人为触发。


请问修正了此bug的版本是哪个版本?代码大约在哪里。我尝试把修改bug的代码移植过去试试。

很奇怪,这个问题出现了,骨架 GameObject 是场景的直接部分,没有任何延迟加载机制。
It is very strange that the problem occurs and the skeleton GameObject is a direct part of the scene without any delayed loading mechanism.

您是否可能在运行时调用AddSkeletonGraphicComponent来添加组件? 这是在运行时侧每次写入 skeletonDataAsset 的唯一情况。 还请检查您是否曾经写过 skeletonGraphic.skeletonDataAsset
Are you perhaps calling AddSkeletonGraphicComponent to add the component at runtime? This is the only occurrances where skeletonDataAsset is every written to on the runtime side. Please also check if you are ever writing to skeletonGraphic.skeletonDataAsset.

您能否向我们发送一个仍然演示此问题的最小 Unity 项目?您可以将其作为 zip 包发送至
answer: 演示程序无法重现。游戏中一共大约100个spine动画, 但只有两三个动画偶尔会发现出现这种问题,概率太小,没有办法人为触发。

错误是否总是发生在相同的骨架上(例如,100 个中有 2 个相同)? 您是否可以尝试通过移除大多数没有问题的骨架并在其中只有一个场景来最小化大型项目? 如果它仍然只在 2% 的时间内发生,那也没关系,只要它有时会发生。
Does the error always occur at the same skeletons (e.g. the same 2 out of 100)? Could you perhaps try if you can minimize the large project by removing most non-problematic skeletons and have only one scene in it? It is ok if it still happens in only 2% of the time, as long as it happens sometimes.

请问修正了此bug的版本是哪个版本?代码大约在哪里。我尝试把修改bug的代码移植过去试试。

该错误修复仅在 InitializeUpdate / LateUpdate 中添加了空检查和提前返回(类似于您手动添加的内容)。 所以它可以防止异常,但不会防止 skeletonDataAsset 为空。 因此,我认为不幸的是它不会帮助你。
The bugfix only added a null check and early-return in Initialize and Update / LateUpdate (similar to what you added manually). So it prevents an exception but does not prevent skeletonDataAsset from being null. Thus I assume that it will not help you unfortunately.