I want to make a c# script of a banner rotator, please guide to how can i do this ?
I can use this code to load an image from the url, perfect.
Step 2: How will i make sure the image is loaded ? and once it is loaded how should i say
- wait for 5 secs and load new
-and then the 3rd url in same manner
and now - cycle this process
Read your documentation on the WWW object, you will find an “Error” handler.
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
public bool bannerLoaded = false;
IEnumerator Start() {
WWW www = new WWW(url);
yield return www;
if(www.error == null){
renderer.material.mainTexture = www.texture;
bannerLoaded = true;
}
}
}
Sorry but i did not get you
My friend, I could not write it any clearer.
Read the documentation about WWW.error.
Look at the code where I applied this to your code, see the differences.
got it - Returns an error message if there was an error during the download
Now, i have to start counting 5 seconds after bannerLoaded = true; and then change the value of url and load it, then i have to make a cycle
I will work it out i believe.
Fairly simple. You are Awesome ![]()