如何解决从 git 中提取项目后,Unity 无法识别某些 .cs 文件
我目前正在使用 Unity 2020.3.3f1 开发一个项目。我使用 git 版本控制系统并将我的项目存储在 Bitbucket 存储库中。当我将我的项目克隆/拉到另一台计算机(尤其是使用 macos)时,我的一些 cs.文件在项目视图中显示为未知文件(不是脚本),并且其他一些类找不到在该文件上定义的类。当我右键单击并选择“重新导入”cs 文件时,立即恢复并成功构建。
当我尝试通过 Unity Cloud build 构建我的项目时,这给我带来了一个问题, 因为我收到了关于一些确实存在的缺失类的错误。
[Unity] Initialize engine version: 2020.3.6f1 (338bb68529b2)
3: [Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/ToonyColorsPro.Editor.dll
4: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(192,13): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
5: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/ShaderProperty.cs(417,40): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
6: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(173,59): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
7: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(192,13): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
8: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/ShaderProperty.cs(417,40): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
9: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(173,59): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
10: ! build of 'default-ios-ad-hoc' failed. exit
11: publishing finished successfully.
12: Finished: FAILURE
之后我尝试从 Mac 设备中提取项目,该项目也无法识别相同的 MaterialLayer.cs。我使用“重新导入”轻松恢复。 我的项目设置/资产序列化:已设置强制文本和“版本控制/可见元文件”。
解决方法
这是一个长镜头,我写答案只是因为我可以在这里附上图片:
C# 解决方案中的每个文件都有属性:
所以我的建议是仔细检查那些“丢失的”、“未知的”.cs
文件是否与那些被正确识别的 .cs
文件具有相同的属性设置。
如果您在 git 上使用 LFS,那么当 LFS 因错误而拉取或元文件在拉取文件期间被破坏时,有时会发生此问题,请仔细检查您的 .gitattributes
。可能是错误地分配了 .meta
的合并选项。我正在为我的项目使用 this .gitattributes
,这仍然没有问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。