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

スクリプト言語

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

Texture2D.Texture2D

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 function Texture2D(width: int, height: int)
public Texture2D(int width, int height);
public def Texture2D(width as int, height as int)

Description

新規の空のテクスチャを作成します

テクスチャは、サイズは width × height となり、ARGB32 TextureFormat (テクスチャ形式)、ミップマップつきおよび sRGB カラー空間です。 通常は作成した後、テクスチャの色を設定したいと思うでしょう。 SetPixel、SetPixels、Applyの関数を使用して

	function Start () {
		// Create a new texture and assign it to the renderer's material
		var texture = new Texture2D (128, 128);
		renderer.material.mainTexture = texture;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        Texture2D texture = new Texture2D(128, 128);
        renderer.material.mainTexture = texture;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		texture as Texture2D = Texture2D(128, 128)
		renderer.material.mainTexture = texture

See Also: SetPixel, SetPixels, Apply 関数

public function Texture2D(width: int, height: int, format: TextureFormat, mipmap: bool)
public Texture2D(int width, int height, TextureFormat format, bool mipmap);
public def Texture2D(width as int, height as int, format as TextureFormat, mipmap as bool)

Description

新規の空のテクスチャを作成します

テクスチャはwidth(幅)・height(高さ)、与えられたフォーマット、 ミップマップの有無にかかわらず、直線またはsRGB色空間のいずれかで構成されます。 通常は作成した後、テクスチャの色を設定したいと思うでしょう。 SetPixel、SetPixels、Applyの関数を使用して

	function Start () {
		// Create a new texture and assign it to the renderer's material
		var texture = new Texture2D(128, 128, TextureFormat.ARGB32, false);
		renderer.material.mainTexture = texture;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        Texture2D texture = new Texture2D(128, 128, TextureFormat.ARGB32, false);
        renderer.material.mainTexture = texture;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		texture as Texture2D = Texture2D(128, 128, TextureFormat.ARGB32, false)
		renderer.material.mainTexture = texture

See Also: SetPixel, SetPixels, Apply 関数

public function Texture2D(width: int, height: int, format: TextureFormat, mipmap: bool, linear: bool)
public Texture2D(int width, int height, TextureFormat format, bool mipmap, bool linear);
public def Texture2D(width as int, height as int, format as TextureFormat, mipmap as bool, linear as bool)

Description

See Also: SetPixel, SetPixels, Apply 関数