Unity Error error CS2001: Source file :XXXXXXX.cs”could not be found.

204 阅读1分钟

error CS2001: Source file :XXXXXXX.cs”could not be found.

标题
Unity版本2021.1.18f1c1
VS版本vs2022

可能的触发方式

  1. Unity单独运行并不会出错,当将VS附加到Unity的时候可能就会提示这个错误
  2. 导入一个新的UnityPackage包的时候

参考文档

  1. github.com/xamarin/xam…

  2. forum.unity.com/threads/err…

  3. forum.unity.com/threads/fir…

图片.png

图片.png

解决方式

方式一

  1. 创建缺少的脚本的其中一个,如果过还报错就多创建几个,
  2. 关闭VS,
  3. 删除sln,
  4. 打开VS,
  5. 附加,
  6. 运行,
  7. 运行的时候删除脚本,就行了。

方式二

  1. 将路径换的短一些,可能是路径太长了

感谢

感谢:

  1. blackjack
  2. **
    在深夜提供支持。