版本: Unity 6 (6000.0)
语言英语
  • C#

Color.gray

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交的内容,但我们会阅读用户提供的每个建议的更改,并在适用情况下进行更新。

关闭

提交失败

由于某种原因,您的建议更改无法提交。请 <a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

public static Color gray;

描述

灰色。RGBA 为 (0.5, 0.5, 0.5, 1)。

//Attach this script to a GameObject with a Renderer (go to Create>3D Object and select one of the first 6 options to create a GameObject with a Renderer automatically attached).
//This script changes the Color of your GameObject’s Material when your mouse hovers over it in Play Mode.

using UnityEngine;

public class Example : MonoBehaviour { Renderer m_Renderer;

void Start() { //Fetch the Renderer component of the GameObject m_Renderer = GetComponent<Renderer>(); }

//Run your mouse over the GameObject to change the Renderer's material color to gray void OnMouseOver() { m_Renderer.material.color = Color.gray; }

//Change the Material's Color back to white when the mouse exits the GameObject void OnMouseExit() { m_Renderer.material.color = Color.white; } }