c# - Assets\Scripts\Player.cs(19,45):错误 CS0117:“颜色”不包含“红色”的定义
问题描述
Assets\Scripts\Player.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;
}
}
推荐阅读
- angular - 提供的服务未被后代组件使用
- regex - 如何在 URI 中获取数字 id?
- azure - 在 Azure 事件中心/blob 存储中查询事件
- microsoft-graph-api - 创建事件返回 ErrorPropertyValidationFailure
- python - 人类性别分类 - 训练和验证准确性不动
- node.js - 使用 Traefik 构建网络
- jakarta-ee - 优雅地处理wildfly组件关闭
- javascript - Angular - 模板驱动表单 - 控制器中的自定义验证器功能
- javascript - Testcafe:如何测试请求的 POST 参数
- javascript - sessionStorage 在 IE 和 Chrome 中不起作用