Version: 2023.1
언어: 한국어
public static Color red ;

설명

Solid red. RGBA is (1, 0, 0, 1).

Returns a solid red Color. RGBA is (1, 0, 0, 1). Use it to change or compare the Color of a GameObject.

//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 red void OnMouseOver() { m_Renderer.material.color = Color.red; }

//Change the Material's Color back to white when the mouse exits the GameObject void OnMouseExit() { m_Renderer.material.color = Color.white; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961