using UnityEngine; using System.Collections; using System.Runtime.InteropServices; using UnityEngine.Networking; using System.Globalization; public class Loadlogo : MonoBehaviour { //[DllImport("__Internal")] //public static extern void ImageUploaderInit(); #if (UNITY_STANDALONE_WIN && !UNITY_EDITOR) public static IEnumerator LoadColors (string url) { print("Loaed LOGO 1"); Texture2D tex= (Texture2D)Resources.Load("LibrairyCSV/logo"); _G.LOGO = tex; Sprite mySprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f); GameObject.Find("Logo").GetComponent().sprite=mySprite; yield return null; } #else public static IEnumerator LoadColors (string url) { url =url+"?"+Random.value.ToString(); print("url======" + url); using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(url)) { yield return www.SendWebRequest(); //yield return new WaitForSeconds(2); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); } else { print("Loaed LOGO 3===" + url); Texture2D tex = DownloadHandlerTexture.GetContent(www); _G.LOGO = tex; Sprite mySprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f); string Name = "logo"; if (url.IndexOf("logo2") != -1) { Name = "logo2"; } GameObject.Find(Name).GetComponent().sprite = mySprite; } } } #endif public static void FileSelected(string url) { StaticCoroutine.Start(LoadColors (url)); } public static void Start () { //ImageUploaderInit (); } }