【问题标题】:Can't add script component because the script class cannot be found? what mean this is if all is ok?由于找不到脚本类,无法添加脚本组件?如果一切正常,这意味着什么?
【发布时间】:2022-11-09 21:59:17
【问题描述】:

为 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));
    }
}

【问题讨论】:

  • 请您也显示您的 UnityScript 代码,因为到目前为止您只显示了您的 C# 代码。
  • 这个问题是关于c#,而不是unityscript

标签: c# unity3d


【解决方案1】:

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

【讨论】:

  • 同样的问题
【解决方案2】:

我有同样的问题,当我删除 system.collections 和 system.collections.generic 但我需要使用 Ienumerator 所以我不能删除 system.collections

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-18
    • 2011-06-04
    • 2013-08-30
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多