新規の空のテクスチャを作成します
テクスチャは、サイズは 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
新規の空のテクスチャを作成します
テクスチャは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