public static void PopMatrix ();

描述

从矩阵堆栈顶部恢复模型、视图和投影矩阵。

更改模型、视图或投影矩阵会覆盖当前的渲染矩阵。 最好使用 GL.PushMatrixGL.PopMatrix 保存和恢复这些矩阵。

另请参阅:PushMatrix 函数。

using UnityEngine;

public class Example : MonoBehaviour { // Draw a yellow line from the botton left to the // top right of the screen Material mat;

void OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); // Save the current state 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(); // Pop changes. } }