Version: 2017.2

GL.PushMatrix

切换到手册
public static void PushMatrix ();

描述

将投影和 modelview 矩阵保存到矩阵堆栈。

更改 modelview 或投影矩阵会重写当前摄像机的参数。 可使用 GL.PushMatrixGL.PopMatrix 保存和恢复这些矩阵。

另请参阅: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.LoadPixelMatrix(); GL.Color(Color.yellow); GL.Begin(GL.LINES); GL.Vertex3(0, 0, 0); GL.Vertex3(Screen.width, Screen.height, 0); GL.End(); GL.PopMatrix(); } }