Version: 2018.1
public float g ;

説明

緑成分

The value ranges from 0 to 1.

//Attach this script to a GameObject with a Renderer attached to it
//Use the sliders in Play Mode to change the Color of the GameObject's Material

using UnityEngine;

public class Example : MonoBehaviour { Renderer m_Renderer; //Set the Color to white to start off public Color color = Color.white;

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

private void OnGUI() { //Sliders for the red, green and blue components of the Color color.r = GUI.HorizontalSlider(new Rect(0, 00, 100, 30), color.r, 0, 1); color.g = GUI.HorizontalSlider(new Rect(0, 40, 100, 30), color.g, 0, 1); color.b = GUI.HorizontalSlider(new Rect(0, 80, 100, 30), color.b, 0, 1);

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