Hello,
well back @ work i get some trouble with this script…
I want to load a Webpage into a Texture.
First i call the webpage … then i translate it to a .jpg
last i load it into a texture…
sometime it works somtime it crashes… ???
so if you have a idea what going wrong plz tell it ![]()
thank you
using UnityEngine;
using System.Collections;
public class JLoadPage : MonoBehaviour {
public Material pageMaterial;
public Material pageMaterialerror;
bool loading = true;
float nextUpdate;
public float reloadtime = 15.0f;
// Use this for initialization
void Start () {
StartCoroutine(MyLoadPage("http://en.wikipedia.org/wiki/Special:Random"));
}
IEnumerator MyLoadPage(string url) {
WWW www = new WWW("http://www.i-dvd.net/unitycallweb.php?url=" + WWW.EscapeURL(url));
while (![url]www.isDone[/url]) {
yield return www;
}
if ([url]www.error[/url] == null) {
string str = [url]www.data;[/url]
www = new WWW(str);
while (![url]www.isDone[/url]) {
yield return www;
}
if ([url]www.error[/url] == null) {
pageMaterial.mainTexture = [url]www.texture;[/url]
}
else {
// Debug.Log("error2 = '" + [url]www.error[/url] + "'");
pageMaterial.mainTexture = pageMaterialerror.mainTexture;
}
}
else {
// Debug.Log("error = '" + [url]www.error[/url] + "'");
pageMaterial.mainTexture = pageMaterialerror.mainTexture;
}
nextUpdate = Time.time + reloadtime;
loading = false;
}
// Update is called once per frame
void FixedUpdate () {
if ((loading == false) (Time.time > nextUpdate)) {
StartCoroutine(MyLoadPage("http://en.wikipedia.org/wiki/Special:Random"));
loading = true;
}
}
}