NGUIのUITextureの画像を入れ替えるサンプル。
1. NGUIのUITextureをHierarchyへ追加する。
2. 以下のスクリプトをUITextureへ追加する。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  | 
						using UnityEngine; using System.Collections; public class TestUITexture : MonoBehaviour { 	public Texture2D _texture1; 	public Texture2D _texture2; 	UITexture _texture; 	void Awake() 	{ 		_texture = GetComponent<UITexture>(); 	} 	void Start() 	{ 		_texture.mainTexture = _texture1; 		Invoke("ChangeTexture", 5); 	} 	void ChangeTexture() 	{ 		_texture.mainTexture = _texture2; 	} }  | 
					
3. InspectorでTexture1とTexture2にテクスチャを設定する。
シーンを再生するとUITextureにはTexture1の画像が表示され、5秒後にTexture2の画像に入れ替わります。

コメントを残す
コメントを投稿するにはログインしてください。