脚本不继承可以管理脚本的本机类

사랑수*_*랑수학 2 unity-game-engine

大家。我是初学者统一用户。当我学习团结。我的 C# 脚本文件没有插入预制件。并返回错误消息:脚本没有继承可以管理脚本的本机类。

这是我的 C# 脚本代码。

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

public class unPlayerMovement
{
    private Transform tr;

    public float moveSpeed = 30.0f;
    public float rotSpeed = 150.0f;
    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;



tr = GetComponent<Transform>();


    }

    // Update is called once per frame
    void Update()
    {
        float h = Input.GetAxis("Mouse X");
        float v = Input.GetAxis("Vertical");

        Move();
    }
    void Move(float h, float v)
    {
        tr.Rotate(0, v * moveSpeed * Time.deltaTime, 0);
        tr.Translate(0, 0, h * rotSpeed * Time.deltaTime);
    }
}



And this is my Unity screen.
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

bol*_*t19 6

刚好也有这个问题。检查类名是否与文件名完全相同,这为我修复了它。

在您的情况下,检查该类unPlayerMovement是否在名为unPlayerMovement.cs