言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

GL.Color

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

Sumbission failed

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

Close

Cancel

public static function Color(c: Color): void;
public static void Color(Color c);
public static def Color(c as Color) as void

Description

現在の頂点カラーを設定します

これはOpenGLでの glColor4f(c.r,c.g,c.b,c.a); と同じような 機能性を持つものです。 頂点ごとのカラーを異なるハードウェアで確実に動作させるには、 カラーチャンネルをバインドするシェーダーを使用する必要があります。 詳しくはBindChannelsを参照してください。 この関数はGL.BeginとGL.End関数の間で呼び出すことができます。

	// Draws a red line from the bottom right
	// to the top left of the Screen
	// And a yellow line from the bottom left
	// to the top right of the Screen
	var mat : Material;

	function OnPostRender() {
		if (!mat) {
			Debug.LogError("Please Assign a material on the inspector");
			return;
		}
		GL.PushMatrix();
		mat.SetPass(0);
		GL.LoadOrtho();
		GL.Begin(GL.LINES);
		GL.Color(Color.red);
		GL.Vertex3(1,0,0);
		GL.Vertex3(0,1,0);
		GL.Color(Color.yellow);
		GL.Vertex3(0,0,0);
		GL.Vertex3(1,1,0);
		GL.End();
		GL.PopMatrix();
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Material mat;
    void OnPostRender() {
        if (!mat) {
            Debug.LogError("Please Assign a material on the inspector");
            return;
        }
        GL.PushMatrix();
        mat.SetPass(0);
        GL.LoadOrtho();
        GL.Begin(GL.LINES);
        GL.Color(Color.red);
        GL.Vertex3(1, 0, 0);
        GL.Vertex3(0, 1, 0);
        GL.Color(Color.yellow);
        GL.Vertex3(0, 0, 0);
        GL.Vertex3(1, 1, 0);
        GL.End();
        GL.PopMatrix();
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public mat as Material

	def OnPostRender() as void:
		if not mat:
			Debug.LogError('Please Assign a material on the inspector')
			return
		GL.PushMatrix()
		mat.SetPass(0)
		GL.LoadOrtho()
		GL.Begin(GL.LINES)
		GL.Color(Color.red)
		GL.Vertex3(1, 0, 0)
		GL.Vertex3(0, 1, 0)
		GL.Color(Color.yellow)
		GL.Vertex3(0, 0, 0)
		GL.Vertex3(1, 1, 0)
		GL.End()
		GL.PopMatrix()