Version: 2020.1

GL.TexCoord

切换到手册
public static void TexCoord (Vector3 v);

描述

为所有纹理单位均设置当前纹理坐标 (v.x,v.y,v.z)。

在 OpenGL 中,当未提供多纹理处理时,其与所有纹理单位的 glMultiTexCoordglTexCoord 相匹配。在其他图形 API 中,对应的 功能是模拟实现的。

仅在以下情况时使用 Z 组件:
1.您访问立方体贴图(这是您使用矢量坐标访问的,因此为 x、y 和 z)。
2.您进行“投影纹理”,在这种情况下,X 和 Y 坐标除以 Z 可获得最终坐标。这最适用于水反射等类似情形。

此函数只能在 GL.BeginGL.End 函数之间加以调用。

using UnityEngine;

public class ExampleScript : MonoBehaviour { // Draws a Quad in the middle of the screen and // Adds the material's Texture to it.

Material mat; void OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); mat.SetPass(1); GL.Color(new Color(1, 1, 1, 1)); GL.LoadOrtho(); GL.Begin(GL.QUADS); GL.TexCoord(new Vector3(0, 0, 0)); GL.Vertex3(0.25f, 0.25f, 0); GL.TexCoord(new Vector3(0, 1, 0)); GL.Vertex3(0.25f, 0.75f, 0); GL.TexCoord(new Vector3(1, 1, 0)); GL.Vertex3(0.75f, 0.75f, 0); GL.TexCoord(new Vector3(1, 0, 0)); GL.Vertex3(0.75f, 0.25f, 0); GL.End(); GL.PopMatrix(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961