言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Graphics.DrawTexture

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function DrawTexture(screenRect: Rect, texture: Texture, sourceRect: Rect, leftBorder: int, rightBorder: int, topBorder: int, bottomBorder: int, color: Color, mat: Material = null): void;
public static void DrawTexture(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, Material mat = null);
public static def DrawTexture(screenRect as Rect, texture as Texture, sourceRect as Rect, leftBorder as int, rightBorder as int, topBorder as int, bottomBorder as int, color as Color, mat as Material = null) as void

Parameters

screenRect テクスチャを表示する位置。左上が(0, 0) になる
sourceRect テクスチャの領域。左下が(0, 0) になる
rightBorder Number of pixels from the right that are not affected by scale.
topBorder Number of pixels from the top that are not affected by scale.
bottomBorder Number of pixels from the bottom that are not affected by scale.
color Color that modulates the output. The neutral value is (0.5, 0.5, 0.5, 0.5). Set as vertex color for the shader.
mat Custom Material that can be used to draw the texture. If null is passed, a default material with the Internal-GUITexture.shader is used.

Description

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

テクスチャを描画します。これはOnGUIオブジェクト内で、EventType型がRepaintの ときに呼び出されます。Graphics.DrawTexture関数より、GUI.DrawTexture関数を使

	// Draws a texture on the screen at 10, 10 with 100 width, 100 height.

	var aTexture : Texture;

	function OnGUI() {
		if(Event.current.type.Equals(EventType.Repaint))
			Graphics.DrawTexture(Rect(10, 10, 100, 100), aTexture);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Texture aTexture;
    void OnGUI() {
        if (Event.current.type.Equals(EventType.Repaint))
            Graphics.DrawTexture(new Rect(10, 10, 100, 100), aTexture);
        
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public aTexture as Texture

	def OnGUI() as void:
		if Event.current.type.Equals(EventType.Repaint):
			Graphics.DrawTexture(Rect(10, 10, 100, 100), aTexture)

用することをお勧めします。