今日のメモ
ランタイム中にSourceImageを変更する。
Image.material.mainTexture
Texture texture = Resources.Load("image path") as Texture;
Image img = GameObject.Find("Canvas/Panel/***").GetComponent();
img.material.mainTexture = texture;
Image.sprite
Texture2D texture = Resources.Load("image path") as Texture2D;
Image img = GameObject.Find("Canvas/Panel/***").GetComponent();
img.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
環境
- OSX El Capitan v10.11
- Unity v5.2.3f1