首页 > 解决方案 > Unity 脚本不继承可以管理脚本的原生类

问题描述

我刚刚在一个空白项目上打开了统一,我正在尝试将脚本链接到我的播放器对象(我正在使用资产商店中的某些东西)并且当我尝试连接它们时出现错误:脚本不继承可以管理脚本的本机类。

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

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

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

我不明白为什么会这样说。

标签: unity3derror-handling

解决方案


确保脚本中的公共类名 与脚本文件名PlayerController相同:.PlayerController.cs

这可能对你有用。


推荐阅读