unity3d 无法添加脚本组件,因为找不到脚本类?如果一切正常,这是什么意思?

xj3cbfub  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(3186)

为2D游戏制作循环背景,当我尝试添加脚本“无法添加脚本组件,因为找不到脚本类”我的代码:

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

public class background : MonoBehaviour
{
    [Range(-1f,1f)][![enter image description here][1]][1]
    public float scrollSpeed = 0.5f;
    private float offset;
    private Material mat;
    void Start()
    {
        mat = GetComponent<Renderer>().material;
    }

    // Update is called once per frame
    void Update()
    {
        offset += (Time.deltaTime*scrollSpeed)/10f;
        mat.SetTextureOffset("_MainTex", new Vector2(offset, 0));
    }
}

wixjitnu

wixjitnu1#

尝试通过复制内容、创建新文件、将内容复制到新文件中并删除旧文件来重新导入脚本。

相关问题