我把spine导入Unity后会出现下面的报错,只要重启unity或者把Spine\Spine\Runtime\spine-csharp\Animation.cs 文件改名就好了,怀疑是找个class的名字跟unity官方的名字冲突
Spine导入后报错问题
@yuanjunquan Sorry for the troubles. Normally you should only receive a warning which says that the Animation
class name already exists, but no compile error stating that the type could not be found. How did you install the spine-unity runtime? Did you install it via the unitypackage and then move the directories to Assets/Framework/ThirdLibs/Spine
? Or did you install it in a different way, e.g. via the Unity Package Manager (if so, how exactly did you install it)?
Which Unity Editor version are you using?
我本地是有一套Spine的版本库的,我是通过代码文件夹移动到Assets/Framework/ThirdLibs/Spine 下的,移动后就会报错
我的unity版本是 2021.3.23f1
@yuanjiashun Thanks for posting the additional information. This is indeed strange. If the error is just displayed after moving the folder and no error is displayed before moving it, it sounds like a bug with Unity's asset management or code project generation system.
If you want to avoid the issue in the future, you could place the spine directories outside the Assets folder so that Unity does not find it (e.g. outside projectname/Assets
in projectname/Modules/Spine/
) and then add it via the Unity Package Manager as local package, via Add Package from Disk..
as described here for UPM packages.
UPM肯定是可以解决问题的,主要是我们需要修改SpinePreferences文件中SPINE_SETTINGS_ASSET_PATH的 位置,还有新增 对于这个文件进行了非空判断
AssetDatabase.CreateAsset(settings, SPINE_SETTINGS_ASSET_PATH);
当文件不存在的时候执行GetOrCreateSettings 会报错
@yuanjiashun Please note that you can still modify the source code when placing them locally in e.g. projectname/Modules/Spine
and add the UPM package via Add package from Disk..
instead of Add package from git URL..
.
I'm not sure I understand the machine translation of the section regarding GetOrCreateSettings
correctly. Are you saying that if you don't modify the source code, you receive an error when GetOrCreateSettings
is executed and the file does not exist yet? This should not happen, as the settings asset should be created automatically when it does not exist (in this code section). If you receive an exception, are you using the latest version of the 4.1 or 4.2-beta runtimes?