Unity 不会执行脚本

问题描述

这是我在 unity 中的超级简单脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class script : MonoBehavIoUr
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Something");
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

我将脚本附加到主摄像头:

main_camera_properties


在我运行 unity 游戏后,控制台是 empty,这意味着脚本不会运行。


这只是我为了测试这个而创建的一个新项目,因为在我原来的项目中,unity 会自发地停止执行脚本。我卸载了旧版本(2019)并安装了新版本(2020)以及 Visual Studio(即使它不是必需的),但没有任何区别。

解决方法

您提供的代码似乎工作正常。控制台窗口为空的一个潜在原因可能是搜索字段中有内容或禁用了标准日志。

enter image description here