using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; using UnityEngine.SceneManagement; using Raumgleiter.BaseRGDK.Development; public class TextureLoader : MonoBehaviour { //WorldReference //public static XXXXXX WorldReference; //Connections //[Header("Connections")] public RawImage NewTexture; /// /// > Downloads a File and saves it to Disk /// GET /file/ /// /// //internal static UnityWebRequest DownloadFile( // string pathServerRelative // ) //{ // //Prepare Request // UnityWebRequest www = UnityWebRequest.Get(Core.GetServerPath() + "/file" + pathServerRelative); // //Add Headers // www.SetRequestHeader(Account.CookieKey, Account.GetCookie()); // //www.SetRequestHeader(Core.AppKey, Core.GetAppPassword()); // //www.SetRequestHeader(Core.PasswordKey, Core.GetBasicAuth(password)); // //Return // return www; //} //Resources //[Header("Resources")] //Attributes //[Header("Attributes")] //Stats //[Header("Stats")] // protected bool IsSetUp = false; //protected bool IsAwoken = false; //Getter //Delegates //------------------------------------------------------------------------------------------------------------------ //awake protected void Awake() { ////Already Awoken? //if (!IsAwoken) //{ // IsAwoken = true; // WorldReference = this; //} } //------------------------------------------------------------------------------------------------------------------ //start protected void Start() { StartCoroutine(GetText()); } IEnumerator GetText() { using (UnityWebRequest www = UnityWebRequest.Get("https://ch.buildup.group/file/id/fb1ca858-1073-4ecb-b6d1-183bfcf7f7ef/buildup%20-%20Holcim%20(Schweiz)%20AG%20-%20Ammocret%C2%AE%20-%20Textur%20%7C%20Abgerieben-Diffuse.jpg")) { yield return www.SendWebRequest(); //Worked? if (string.IsNullOrEmpty(www.error)) { // Show results as text Debug.Log(www.downloadHandler.text); // Or retreive results as binary data byte[] Results = www.downloadHandler.data; Texture2D Tex = new Texture2D(2, 2); Tex.LoadImage(Results); NewTexture.texture = Tex; } else { DBug.Log( www.error, "TextureLoader::GetText", VerbosityLevel._03_Critical); } } } //------------------------------------------------------------------------------------------------------------------ //setup // public void SetUp() // { // Awake(); // IsSetUp = true; // } //------------------------------------------------------------------------------------------------------------------ //destroy //*********************************************************************************************************************** //update //*********************************************************************************************************************** //refresh //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //events //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //private, protected //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //internal //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //public static //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //public //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //getter, setter //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ }