脚本不继承可以管理脚本的本机类 [英] The script don't inherit a native class that can manage a script

查看:39
本文介绍了脚本不继承可以管理脚本的本机类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

everybody. I'm beginner unity user. When i study unity. my C# script file doesn't insert to prefabs. And it return error message : The script don't inherit a native class that can manage a script.

这是我的 C# 脚本代码.

this is my C# script code.

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.

在此处输入图片说明

推荐答案

刚刚也遇到了这个问题.检查类名是否与文件名完全相同,这为我修复了.

Just had this issue too. Check the class name is the exact same as the file name, this fixed it for me.

在您的情况下,检查 unPlayerMovement 类位于名为 unPlayerMovement.cs

In your case check the class unPlayerMovement is in a file called unPlayerMovement.cs

这篇关于脚本不继承可以管理脚本的本机类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆