AssetsScriptsPlayer.cs(19,45):错误CS0117:“颜色”不包含“红色”的定义

c#

AssetsScriptsPlayer.cs(19,45):错误 CS0117:“颜色”不包含“红色”的定义

using System.Drawing;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Color = System.Drawing.Color;


public class Player : MonoBehaviour
{

    public SpriteRenderer[] renderers;

    private void Start() {
        renderers[0].material.color = Color.red;
    }
}

回答

Unity 不使用System.Drawing.Color结构体。你需要UnityEngine.Color改用。您需要做的就是删除这些行using Color = System.Drawing.Color;using System.Drawing;您将使用正确的Color结构,它确实Color.red. 见下文:

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


public class Player : MonoBehaviour
{

    public SpriteRenderer[] renderers;

    private void Start() {
        renderers[0].material.color = Color.red;
    }
}


以上是AssetsScriptsPlayer.cs(19,45):错误CS0117:“颜色”不包含“红色”的定义的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>