问题描述:
刚接触Unity,因为一些原因必须使用 2019-2-14f1 这个版本,安装后出现该问题。
直接新建未做任何修改的项目不能运行,Console里出现两个空错误,如下图:
所有的脚本失效,不能添加,如下:
提示:
Can’t add script component ‘CubeScript’ because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
但是检查发现文件名和类名确是一致的,也不存在编译错误。
解决方式:
Unity 社区的解答
Stack Overflow 的回答
修改Unity安装目录下:Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts\unity_csc.bat 文件
将 "%APPLICATION_CONTENTS%\Tools\Roslyn\csc" /shared %*
修改为:"%APPLICATION_CONTENTS%\Tools\Roslyn\csc.exe" /shared %*
就是csc
后加个.exe
。