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

スクリプト言語

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

Texture2D.GetPixels32

public function GetPixels32(miplevel: int = 0): Color32[];

Description

Color32 形式のピクセルのカラー配列を取得します

この機能は、全体のピクセルカラーの配列を返す テクスチャのミップレベル 平面の配列を返す、ピクセルは右から左にレイアウトされている 下から上に(行の後の行)。配列サイズは使用されるミップレベルの高さ、幅である。 デフォルトのミップレベルはゼロ(ベーステクスチャ)です\nその場合、サイズはテクスチャのサイズにぴたりと一致します。 一般的にミップレベルのサイズは\nmipWidth=max(1,width>>miplevel) そして高さも同様です。 テクスチャはインポートセッティングのRead/Write Enabledフラグを設定しなくてはいけません。でなければこのファンクションは失敗するでしょう。 GetPixels32を使用すると、特に大規模なテクスチャ、繰り返しGetPixelとを呼び出すよりも高速になります。 さらに、GetPixels32は個々のミップマップレベルにアクセスすることができます。

	// Rotate an image 180 degrees by reversing the order
	// of the pixels.
	
	// Source texture.
	var sourceTex: Texture2D;	
	
	
	function Start () {
		// Get the pixel block and reverse the array to
		// rotate the image.
		var pix = sourceTex.GetPixels32();
		System.Array.Reverse(pix);
		
		// Copy the reversed image data to a new texture.
		var destTex = new Texture2D(sourceTex.width, sourceTex.height);
		destTex.SetPixels32(pix);
		destTex.Apply();
		
		// Set the current object's texture to show the
		// rotated image.
		renderer.material.mainTexture = destTex;
	}

See Also: SetPixels, mipmapCount.