C# 渲染器无法';在当前程序集中找不到

C# 渲染器无法';在当前程序集中找不到,c#,unity3d,C#,Unity3d,Assets\Scripts\BGlooper.cs(17,41):错误CS1061:“Renderer”不包含“material”的定义,并且找不到接受“Renderer”类型的第一个参数的可访问扩展方法“material”(是否缺少using指令或程序集引用?) 当我尝试开始场景时,它显示了这一点。有人能帮我吗 [DebuggerDisplay("{" + nameof(GetDebugerDisplay) + "(),nq}")] public cl

Assets\Scripts\BGlooper.cs(17,41):错误CS1061:“Renderer”不包含“material”的定义,并且找不到接受“Renderer”类型的第一个参数的可访问扩展方法“material”(是否缺少using指令或程序集引用?)

当我尝试开始场景时,它显示了这一点。有人能帮我吗

[DebuggerDisplay("{" + nameof(GetDebugerDisplay) + "(),nq}")]
public class BGlooper : MonoBehaviour
{
    public float speed = 0.1f;

    private Material mat;
    private Vector2 offset = Vector2.zero;

    void Start()
    {
        mat = GetComponent<Renderer>().material;
        offset = mat.GetTextureOffset("_Maintex");
    }

    void Update()
    {
        offset.x = offset.x + speed * Time.deltaTime;
        mat.SetTextureOffset("_Maintex", offset);
    }

    private static object GetDebugerDisplay()
    {
        return ToString();
    }
}
[DebuggerDisplay(“{”+nameof(GetDebugerDisplay)+”(),nq}”)]
公共类BGlooper:单行为
{
公共浮子速度=0.1f;
私人材料垫;
专用矢量2偏移=矢量2.0;
void Start()
{
mat=GetComponent().材料;
offset=mat.GetTextureOffset(“_Maintex”);
}
无效更新()
{
偏移量.x=偏移量.x+速度*时间增量;
材料设置纹理偏移(“主纹理”,偏移);
}
私有静态对象GetDebuggerDisplay()
{
返回到字符串();
}
}

我相信您的问题在第31行。据我所知,您不能使用return-ToString()。您必须使用像return object.ToString()这样的对象因为ToString()是一种将某些内容转换为字符串(文本)的方法,所以您可能需要一个对象。我希望它能有所帮助。同样在第17行,似乎“material”不被识别,因此您可能会在项目中对其进行不同的命名。

如果您将
material
改为
material
会发生什么?请将问题标题更改为您问题的简要摘要。另外,请发布实际代码,而不是代码的屏幕截图。