I am trying to get a picture from my website and I have placed the crossdomain.xml file in the root folder but can’t seem to get it to read. I have tried a few different ways but still fall short… Here is my code if it helps?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class FetchImage : MonoBehaviour
{
List msgs = new List ();
IEnumerator Start ()
{
var urls = new string[] {
"http://mySite.com"
};
int port = 843;
//Only needed in WebPlayer
Security.PrefetchSocketPolicy("www.mySite.com", port);
Application.RegisterLogCallback (Logger);
for (var i=0; i< 5; i++) {
var requests = new List ();
foreach (var url in urls) {
var r = new HTTP.Request ("GET", url);
r.Send ();
requests.Add (r);
}
while (true) {
yield return null;
var done = true;
foreach (var r in requests) {
done = done & r.isDone;
}
if (done)
break;
}
foreach (var r in requests)
{
if (r.exception != null) {
Debug.LogError (r.exception);
} else {
var tex = new Texture2D (512, 512);
tex.LoadImage (r.response.Bytes);
renderer.material.SetTexture ("_MainTex", tex);
yield return new WaitForSeconds(1);
}
}
yield return new WaitForSeconds(30);
}
}
void Logger (string condition, string msg, LogType type)
{
msgs.Add (condition);
}
void OnGUI ()
{
GUILayout.BeginVertical ();
foreach (var i in msgs)
GUILayout.Label (i);
GUILayout.EndVertical ();
}
}