【发布时间】: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