Version: 2020.1
public static int QUADS ;

描述

Begin 的模式:绘制四边形。

使用经过的每一组顶点(4 个)绘制四边形。如果经过 4 个顶点,则绘制一个四边形,其中每一个顶点成为该四边形的一个角。如果经过 8 个顶点,则绘制 2 个四边形。

要为 2D 模式绘制设置屏幕,则使用 GL.LoadOrthoGL.LoadPixelMatrix。 要为 3D 模式绘制设置屏幕,则使用 GL.LoadIdentity,然后使用具有所需变换矩阵的 GL.MultMatrix

另请参阅:GL.BeginGL.End

using UnityEngine;

public class Example : MonoBehaviour { // Draw red a rombus on the screen // and also draw a small cyan Quad in the left corner 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.QUADS); GL.Color(Color.red); GL.Vertex3(0, 0.5f, 0); GL.Vertex3(0.5f, 1, 0); GL.Vertex3(1, 0.5f, 0); GL.Vertex3(0.5f, 0, 0);

GL.Color(Color.cyan); GL.Vertex3(0, 0, 0); GL.Vertex3(0, 0.25f, 0); GL.Vertex3(0.25f, 0.25f, 0); GL.Vertex3(0.25f, 0, 0); GL.End(); GL.PopMatrix(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961