Texture2D.Texture2D
static function Texture2D (width : int, height : int) : Texture2D
Description描述
Create a new empty texture.
创建一个新的空纹理
The texture will be width by height size, with an ARGB32 TextureFormat and with mipmaps.
纹理的大小是宽度乘以高度,是ARGB32位纹理格式并带有mipmap
Usually you will want to set the colors of the texture after creating it, using SetPixel, SetPixels and Apply functions.
通常创建它之后你要设置纹理的颜色,使用SetPixel, SetPixels 和 Apply函数。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Start() {
Texture2D texture = new Texture2D(128, 128);
renderer.material.mainTexture = texture;
}
}
function Start () {
// Create a new texture and assign it to the renderer's material
//创建一个新的纹理并分配渲染材质
var texture = new Texture2D (128, 128);
renderer.material.mainTexture = texture;
}
参见: SetPixel, SetPixels, Apply 函数。
• static function Texture2D (width : int, height : int, format : TextureFormat, mipmap : bool) : Texture2D
Description描述
Create a new empty texture.
创建一个新的空纹理
The texture will be width by height size, with a given format and with mipmaps or without.
纹理的大小为宽乘以高,只有给定的格式且有或没有mipmaps
Usually you will want to set the colors of the texture after creating it, using SetPixel, SetPixels and Apply functions.
通常创建它之后你要设置纹理的颜色,使用SetPixel, SetPixels 和 Apply函数。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Start() {
Texture2D texture = new Texture2D(128, 128, TextureFormat.ARGB32, false);
renderer.material.mainTexture = texture;
}
}
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;
}
参见: SetPixel, SetPixels, Apply 函数。