简体   繁体   English

我正在统一开发一个项目,它说“无法加载相关的脚本,请修复任何编译错误并分配一个有效的脚本”

[英]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.

相关问题 Unity 对默认脚本说“相关脚本无效” - Unity saying "the associated script is not valid" for the default scripts “无法加载关联的脚本”错误 Unity。 C# - “The associated script cannot be loaded” Error Unity. C# 我无法在 Unity 中为我的预制件分配脚本 - I cannot assign a script to my prefab in Unity 我是 C# 和 Unity 的新手,找了几个小时后无法在我的脚本中找出这些错误 - I am new to C# and Unity and cannot figure these errors in my script out after looking for hours 重新启动时,Unity 为所有脚本显示消息“无法加载关联的脚本” - Unity displaying message "the associated script cannot be loaded" for all scripts when restarted Unity“无法加载关联脚本”和“Win32Exception:系统找不到指定的文件” - Unity "The associated script can not be loaded" and "Win32Exception: The system cannot find the file specified" 从 2019.1 到 2019.4 更新 Unity 得到这个“关联的脚本无法加载” - Updating Unity from 2019.1 to 2019.4 get this “The associated script can not be loaded” 如何使用 unity 的 Object.FindObjectOfType 解决我无法在脚本中找到有效方法的问题? - How do I fix my failure to find a valid method in a script using unity's Object.FindObjectOfType? 无法从脚本构建 Unity WebGL 项目 - Cannot build Unity WebGL project from script 为什么我无法在 UNITY 中打开脚本 - Why am i unable to open a script in UNITY
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM