错误CS0619与CS1061错误
问题描述:
我看教程它似乎工作,但对我来说,我得到这些错误:错误CS0619与CS1061错误
错误CS0619:
UnityEngine.Component.renderer' is obsolete:
物业 渲染器已被弃用。改用GetComponent()。 (UnityUpgradable) '
和:
错误CS1061:类型
UnityEngine.Component' does not contain a definition for
材料' 和没有扩展方法material' of type
UnityEngine.Component”可以找到(是否缺少使用 指令或程序集的参考?)。
这里的脚本:
using UnityEngine;
using System.Collections;
public class ScrollScript : MonoBehaviour {
public float speed = 0;
void Update() {
renderer.material.mainTextureOffset = new Vector2 (Time.time * speed, 0f);
}
}
答
公共渲染器进行渲染;
空隙开始(){
渲染= this.GetComponent “< ”渲染“>”();
}
不使用引号
有什么不清楚 “而不是物业渲染器已被弃用。使用GetComponent()。”? –