Toshusai blog

知識の保管庫

Unityでテクスチャを動的生成する

公式:https://docs.unity3d.com/ja/2017.4/ScriptReference/Texture2D-ctor.html

幅と高さを指定して空のテクスチャを作成する。

int width = 16;
int height = 16;
Texture2D texture = new Texture2D(width, height);

テクスチャのフォーマット、ミニマップを作成するかどうか、リニアかsRGB色空間かどうかも設定できる。

public Texture2D (int width, int height, TextureFormat format, bool mipmap, bool linear);