Color.red

Unity · Версия 2020.3 LTS · Scripting · Color

Color.red

public static Color red;

Описание

Сплошной красный. RGBA — это (1, 0, 0, 1).

Возвращает сплошной красный цвет. RGBA — это (1, 0, 0, 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 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;
    }
}

Обновлено 17 ноября 2026 г.