ゲーム開発奮闘記

Unity・エフェクト・アプリ開発に関係した記事を書いています

Unity メモ :TextureのOffsetを任意の数値に移動

Material.SetTextureOffset:公式リンク


使用例:
・ボタンを押した時に、Offset (0.0, 0.5)に移動。
・ボタンを離した時に、Offset (0.0, 0.0)に移動。

void OnMouseDown() {
	renderer.material.SetTextureOffset("_MainTex", new Vector2*1;
}

void OnMouseUp() {
	renderer.material.SetTextureOffset("_MainTex", new Vector2*2;
}

(float)をnew Vector2()のカッコの中に入れないとfloatにならないようです。


人気ブログランキングへ

*1:float)0.0, (float)0.5

*2:float)0.0, (float)0.0