Version: 2020.3
言語: 日本語
public static void DrawTexture (Rect screenRect, Texture texture, Material mat= null, int pass= -1);
public static void DrawTexture (Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat= null, int pass= -1);
public static void DrawTexture (Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat= null, int pass= -1);
public static void DrawTexture (Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, Material mat= null, int pass= -1);

パラメーター

screenRect テクスチャに使用するスクリーン上のレクタングル。ピクセルで左上隅の (0,0) の座標。
texture テクスチャを表示する位置。左上が(0, 0) になる
sourceRect 使用するテクスチャの領域。左下隅を (0,0) で正規化された座標。
leftBorder スケールの影響を受けない左からのピクセル数。
rightBorder スケールによって影響されない右端からのピクセル数
topBorder スケールによって影響されない上端からのピクセル数
bottomBorder スケールによって影響されない下端からのピクセル数
color 出力を調節する Color 。中間の値は (0.5, 0.5, 0.5, 0.5) です。シェーダーの頂点カラーとして設定します。
mat カスタム Material テクスチャを描画するために使用できます。 null が渡された場合、 Internal-GUITexture.shader とデフォルトのマテリアルが使用されます。
pass -1 (デフォルト) の場合、マテリアルのすべてのパスを描画します。そうでなければ、指定されたパスだけを描画します。

説明

設定した座標にテクスチャを描画する

If you want to draw a texture from inside of OnGUI code, you should only do that from EventType.Repaint events. It's probably better to use GUI.DrawTexture for GUI code.

using UnityEngine;

public class Example : MonoBehaviour { // Draws a texture on the screen at 10, 10 with 100 width, 100 height.

Texture aTexture;

void OnGUI() { if (Event.current.type.Equals(EventType.Repaint)) { Graphics.DrawTexture(new Rect(10, 10, 100, 100), aTexture); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961