using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
// Use this for initialization
public UITexture uiTexture;
public bool PicReady = false;
void Start() {
NGUIDebug.Log(Time.frameCount + "Before Assignement mainTexture Width is" + uiTexture.mainTexture.height);
StartCoroutine(UpdateImage());
}
public void OnClick() {
NGUIDebug.Log(Time.frameCount + " I clicked the button");
PicReady = true;
}
public void ChangePicReady() {
NGUIDebug.Log(Time.frameCount + " I changed the PicReady from other script");
PicReady = true;
}
IEnumerator UpdateImage() {
while (true) {
yield return new WaitForSeconds
(5); if (PicReady) {
string url = "file://" + PlayerPrefs.GetString("PicPath");
NGUIDebug.Log(Time.frameCount + " PicReady: " + PicReady + " url " + url);
yield return www;
uiTexture.mainTexture = www.texture;
NGUIDebug.Log(Time.frameCount + " After Assigned mainTexture " + uiTexture.mainTexture.height);
}
}
}
}