[英]I am working on a project in unity it is saying “The associated script cannot be loaded, please fix any compile errors and assign a valid script”
I am working on a project in unity it is but none of them are working everyone is saying "The associated script cannot be loaded, please fix any compile errors and assign a valid script".我正在统一开发一个项目,但他们都没有工作,每个人都在说“无法加载相关的脚本,请修复任何编译错误并分配一个有效的脚本”。 I have tried everything like reinstalling unity, using older version etc. What can I do?
我已经尝试了所有方法,例如重新安装 unity、使用旧版本等。我该怎么办? This is one of the scripts
这是脚本之一
using UnityEngine;
public class MouseHandler: MonoBehaviour
{
// horizontal rotation speed
public float horizontalSpeed = 1f;
// vertical rotation speed
public float verticalSpeed = 1f;
private float xRotation = 0.0f;
private float yRotation = 0.0f;
private Camera cam;
void Start()
{
cam = Camera.main;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * horizontalSpeed;
float mouseY = Input.GetAxis("Mouse Y") * verticalSpeed;
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90, 90);
cam.transform.eulerAngles = new Vector3(xRotation, yRotation, 0.0f);
}
}
I think it's because the script name doesn't the class name.我认为这是因为脚本名称不是 class 名称。 Or it could be that there are complier errors but I don't see anything wrong with your script.
或者可能是编译器错误,但我看不出你的脚本有什么问题。 I'm kinda new to C# and I too encountered this error and this is the only fix I know.
我对 C# 有点陌生,我也遇到了这个错误,这是我知道的唯一修复。 If there are others please let me know.
如果还有其他人请告诉我。 Hope this helps: :D
希望这会有所帮助::D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.