Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Color.gray

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static var gray: Color;
public static Color gray;

Description

Gray. RGBA is (0.5, 0.5, 0.5, 1).

no example available in JavaScript
//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; } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答