Quantcast
Channel: Questions in topic: "webrequest"
Viewing all 387 articles
Browse latest View live

Unity WebRequest doesnt download the whole html

$
0
0
Hello, I want to download a html using Unity Webrequest and retrieve the data (its actually google). I want to do this because I want to retrieve the count of results from google search. But when I dwonlload the file, tthe results are just missing. I wrote two different codes but both of them are not working. Heres the first: public class SearchGoogle : MonoBehaviour { public string keyword; private string searchwebsite; string fileName = "MyFile.html"; string html; void Start() { searchwebsite = "https://www.google.com/search?q=" + keyword; Debug.Log(searchwebsite); StartCoroutine(GetText()); Debug.Log("Coroutine gets callt"); } IEnumerator GetText() { UnityWebRequest www = UnityWebRequest.Get(searchwebsite); yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.Log("Error: "); Debug.Log(www.error); } else { html = www.downloadHandler.text; checkfor(); //filecreation var sr = File.CreateText(fileName); sr.WriteLine(www.downloadHandler.text); sr.Close(); } } void checkfor() { string input = html; string search = "
"; int p = input.IndexOf(search); if (p >= 0) { // move forward to the value int start = p + search.Length; // now find the end by searching for the next closing tag starting at the start position, // limiting the forward search to the max value length int end = input.IndexOf("
", start); if (end >= 0) { // pull out the substring string v = input.Substring(start, end - start); Debug.Log(v); // finally parse into a float float value = float.Parse(v); Debug.Log("Value = " + value); } else { Debug.Log("Bad html - closing tag not found"); } } else { Debug.Log("result-stats div not found"); } } } The second is this: public class test : MonoBehaviour { public string keyword; private string link; void Start() { link = "http://google.com/search?q=" + keyword; StartCoroutine(DownloadFile()); } IEnumerator DownloadFile() { var uwr = new UnityWebRequest(link, UnityWebRequest.kHttpVerbGET); string path = Path.Combine(Application.persistentDataPath, "unity3d.html"); uwr.downloadHandler = new DownloadHandlerFile(path); yield return uwr.SendWebRequest(); if (uwr.isNetworkError || uwr.isHttpError) Debug.LogError(uwr.error); else Debug.Log("File successfully downloaded and saved to " + path); } } I would really apreciate if someone could tell me why, none could tell me over at stack.

I am using Unity(2018.4.23f1) WebRequest to access to server. It is working properly in editor but not in android device? Can anybody please give me the solutions here?

$
0
0
I need to access to server for login purpose. It cannot connect to the main portal when i am using android mobile device and giving me error status code 0. It working properly in unity editor. Please let me know if there are some changes required in the settings because it is working some android devices which are older version mine is the latest one.

Link real-time data to unity

$
0
0
How can I link or connect or read real time data from a website or database? Basically I have this model where I show it using the unity app, but at the same time, that model have some kind of reading, like the reading of water level and so on, so I'm trying to link those reading(real time data) into the unity app, so even when the reading is changed, the data in the unity app will also change according to the reading.

Unity 5.6.7 - UnityWebRequest SSL/HTTPs

$
0
0
Hi, While using **Unity 5.6.7**, I'm having issues accessing a secured server through HTTPS on Android. javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. This is not an issue when using recent versions of Unity as *UnityWebRequest* has the *CertificateHandler* attribute where I can validate the connection, unfortunately in 5.6.7 this does not exist and I would like to avoid updating the engine. Please help! Cheers,

UnityWebRequest.Post not passing parameters to Web API

$
0
0
I have created a simple WebAPI that I have working with the following postman call [POST] http://localhost:58452/api/getGameData?TransactionId=123456789&LevelName=Test&DeviceType=Android Works great... no issues in postman what so ever. From within Unity... WWWForm form = new WWWForm(); form.AddField("TransactionId", "123456789"); form.AddField("LevelName", "Test"); form.AddField("DeviceType", "Android"); UnityWebRequest www = UnityWebRequest.Post("http://localhost:58452/api/getGameData", form); yield return www.SendWebRequest(); I'm able to debug into the web api code on the server and each time the passed in variables are null. This works fine in postman so I'm not sure what I'm missing here on the Unity side. Any help would be appreciated.

POST to HTTP not working

$
0
0
I've been trying to get [this tutorial][1] to work with UnityWebRequest. GET works fine, but when I try to POST I keep getting this error: register.php: Error: Cannot connect to destination host UnityEngine.Debug:Log(Object) d__10:MoveNext() (at Assets/Scripts/RegistrationMenu.cs:63) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) Both `register.php` and `test.php` work as expected in browser. Here's the C# code: using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI; using UnityEngine.Networking; public class RegistrationMenu : MonoBehaviour { [SerializeField] GameObject MainPanel; [SerializeField] GameObject ScorePanel; [SerializeField] TMP_InputField NameField; [SerializeField] TMP_InputField PasswordField; [SerializeField] TMP_InputField PasswordConfirmField; [SerializeField] Button SubmitButton; [SerializeField] string RegisterURL = "http://184.88.11.231/gardenlife/register.php"; public void Start() { StartCoroutine(test()); } private IEnumerator test() { var TestURL = "http://184.88.11.231/gardenlife/test.php"; UnityWebRequest webRequest = UnityWebRequest.Get(TestURL); // Request and wait for the desired page. yield return webRequest.SendWebRequest(); string[] pages = TestURL.Split('/'); int page = pages.Length - 1; if (webRequest.isNetworkError) { Debug.Log(pages[page] + ": Error: " + webRequest.error); } else { Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text); } } public void CallRegister() { StartCoroutine(Register()); } private IEnumerator Register() { WWWForm form = new WWWForm(); form.AddField("name", NameField.text); form.AddField("password", PasswordField.text); UnityWebRequest webRequest = UnityWebRequest.Post(RegisterURL, form); webRequest.chunkedTransfer = false; // Request and wait for the desired page. yield return webRequest.SendWebRequest(); string[] pages = RegisterURL.Split('/'); int page = pages.Length - 1; if (webRequest.isNetworkError) { Debug.Log(pages[page] + ":\nError: " + webRequest.error); } else { Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text); } } public void GoToMain() { MainPanel.SetActive(true); this.gameObject.SetActive(false); } public void GoToScore() { ScorePanel.SetActive(true); this.gameObject.SetActive(false); } public void VerifyInputs() { SubmitButton.interactable = (NameField.text.Length >= 8 && PasswordField.text.Length >= 8 && PasswordField.text == PasswordConfirmField.text); } } Any advice would be greatly appreciated. [1]: https://youtu.be/4W90-mh70JY

Unity HTTP Post WebRquest not working on some Android Devices

$
0
0
I am having an issue with making post requests on some Android devices, Here is my enumerator for web request [SerializeField] private Text _statusText; //for debugin [SerializeField] private Text _donloadHandlerText; //for debugin public IEnumerator GetEvent(string url, string bodyJsonString, System.Action callback) { print(bodyJsonString); var request = new UnityWebRequest(url, "POST"); byte[] bodyRaw = Encoding.UTF8.GetBytes(bodyJsonString); request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); request.timeout = 10; //Setting the timeout request; yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { Debug.Log("Network Error: " + request.responseCode + request.error); _statusText.text = "Event Call Status: " + request.responseCode + " " + request.error;//for debugin } else { Debug.Log("Status Code: " + request.responseCode); _statusText.text = "Event Call Status: " + request.responseCode;//for debugin //getting the body from call Debug.Log(request.downloadHandler.text); _donloadHandlerText.text = "Download Handler: " + request.downloadHandler.text; var data = request.downloadHandler.text; EventCallBack eventCallBack = EventCallBack.CreateFromJSON(data); callback(eventCallBack); } } This code works perfectly fine on Unity Editor, iOS devices. However, here is the interesting part on Andriod devices the post request works fine on wifi network. But if the user switches to cellular mobile network on some Android phone I am not able to make any post-call. I have checked to see if the application does have access to cellular mobile network if (Application.internetReachability == NetworkReachability.NotReachable) { //Change the Text _networkStatus.text = "NetWork Status: " + "Not Reachable."; } //Check if the device can reach the internet via a carrier data network else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork) { _networkStatus.text = "NetWork Status: " + "Reachable via carrier data network."; } //Check if the device can reach the internet via a LAN else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { _networkStatus.text = "NetWork Status: " + "Reachable via Local Area Network."; } and turned out the application does have access to the cellular mobile network. I also wanted to see what happen to post-call on Andriod devices which are affected by this problem. I get the status call 200 which means the call success but in the body, I get a strange html fragment and the most interesting part is that I don’t actually receive any call in the backend but somehow I get responseCode 200 from the webRequest. Anyone has any idea that can help, please let me know. I have tried everything to find out what is happening but no look so far. Note: I am also aware that Andiond on higher API(28+) level block http call by default I have added `

UnityWebRequest returns different errors for right urls

$
0
0
I'm using UnityWebRequest to download asset bundles from my server. Sometimes the following code returns different exceptions such as Failed to receive data , Cannot resolve destination host, Cannot connect to destination host, Unknown Error, Request timeout and so on. Here is the part of my code. UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url,(uint)data.version,0); Debug.Log ("Downloading " + url); yield return www.SendWebRequest(); AssetBundle bundle = null; if(www.isNetworkError || www.isHttpError) { Debug.Log(www.isNetworkError); Debug.Log(www.isHttpError); Debug.Log(www.error); if (ARSceneManager.Instance != null) data.downloadAssetBundlesCompleted?.Invoke(null); } else { bundle = DownloadHandlerAssetBundle.GetContent(www); } if (!string.IsNullOrEmpty(www.error)) { throw new Exception("WWW download: " + url + ", " + www.error); } So I get the errors for different urls and in some cases. P.S. the same URL works for the next time, also it works in browser too. So I don't think there are issues with urls. Thanks.

How to make a script wait for a UnityWebRequest to finish for WebGL without a coroutine?

$
0
0
Hello! I'm writing code that goes out to an API and gets data in JSON, I have created classes to use the JSON utility to decode this JSON. Therefore(As far as I'm aware) I need to use a method instead of a coroutine to return the data that I get from the JSON decode. So in order to make the method wait for the UnityWebRequest to finish, I was using a while method. I found out that it will make the WebGL freeze, So I've been trying to find a way to make it wait without using a coroutine. **Here's My Code: ** public TaskList FindTasks() { const string URL = "https://api.harvestapp.com/v2/tasks"; using (UnityWebRequest www = UnityWebRequest.Get(URL)) { www.SetRequestHeader("user-agent", "MyApp (max@benmiller.com)"); www.SetRequestHeader("Authorization", "Bearer " + AccessToken); www.SetRequestHeader("Harvest-Account-Id", AccountID); www.Send(); while (!www.isDone) { } new WaitUntil(www.isDone); if (www.isHttpError) { Debug.LogError("UnityWebError: " + www.error); return null; } else { string Value = www.downloadHandler.text; TaskList JsonData = JsonUtility.FromJson(Value); return JsonData; } } } [Serializable] public class TaskList { public List tasks; } [Serializable] public class Task { public int id; public string name; public bool billable_by_default; public string default_hourly_rate; // No clue what type this should be. public bool is_default; public bool is_active; public DateTime created_at; public DateTime updated_at; }

Unity AssetBundle One-time download

$
0
0
I was having a serious problem about assetbundles, i am trying to do a system which assetbundle will be loaded only one time. If it exits on the project files it will not download and will find the assetbundle existing on device. In my 1 week of research i couldnt found any solution to this problem.. I cant get any reference to the assetbundles in the project and i dont know how to get it (names, AssetBundle variable references, etc.) I can download from direct link on google drive but i cant check the file size without downloading also... I dig in every unity script documentation for 2019.3.4LTS about AssetBundles and how can i do this one-time download.. Could someone give me instructions about this topic ? I am really desperate..

Loading contents from a shared folder at run time

$
0
0
I have two machines connected to a private network. Unity application runs in one machine (#1) and images are stored in the other (#2). How can I access the Images from #2 when unity is launched in #1. Using UnityWebRequest, I am able to access the images in the local machine. But the same doesn't work when I try to access the images in the remote machine.

UnityWebRequest.error return "cannot connect to destination host" on iOS13.5.1

$
0
0
I wanted to post a card to trello using UnityWebRequest.Post, but UnityWebRequest.error return "cannot connect to destination host" on iOS13 (tested on iOS13.5.1). It worked on iOS12.3.1, Android, and UnityEditor. Any idea what is going wrong? Here are the code: private void CheckWebRequestStatus( string errorMessage, UnityWebRequest uwr ) { if ( !string.IsNullOrEmpty( uwr.error ) ) { Debug.Log( errorMessage + ": " + uwr.error ); } } public IEnumerator UploadCardCO(TrelloCard card) { WWWForm post = new WWWForm(); post.AddField("name", card.name); post.AddField("desc", card.desc); post.AddField("pos", card.pos); post.AddField("due", card.due); post.AddField("idList", card.idList); UnityWebRequest uwr = UnityWebRequest.Post(cardBaseUrl + "?" + "key=" + key + "&token=" + token, post); uwr.timeout = m_uploadCardWebRequestTimeOut; yield return uwr.SendWebRequest(); CheckWebRequestStatus( "Could not upload new card to Trello", uwr ); } Here are the XCode log: 2020-08-27 14:10:24.786708+0800 MYAPP[929:197965] Task <6A508741-B288-4B15-BC95-516F58A4D2D3>.<1> HTTP load failed, 561/1771 bytes (error code: -1005 [4:-4]) 2020-08-27 14:10:24.795008+0800 MYAPP[929:197965] Task <6A508741-B288-4B15-BC95-516F58A4D2D3>.<1> HTTP load failed, 561/1771 bytes (error code: -1005 [4:-4]) 2020-08-27 14:10:24.798028+0800 MYAPP[929:197958] Task <6A508741-B288-4B15-BC95-516F58A4D2D3>.<1> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=-4, NSUnderlyingError=0x281712d00 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x100201bb1288d6130000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <6A508741-B288-4B15-BC95-516F58A4D2D3>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalUploadTask <6A508741-B288-4B15-BC95-516F58A4D2D3>.<1>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://api.trello.com/1/cards/?key=KEY&token=TOKEN, NSErrorFailingURLKey=https://api.trello.com/1/cards/?key=KEY&token=TOKEN, _kCFStreamErrorDomainKey=4} Could not upload new card to Trello: Cannot connect to destination host Any advice, solution or suggestion would be much appreciated.

UnityWebRequest returns an empty string

$
0
0
Version: 2019.3.11f1 I tried to add a simple online leaderboard to my game. I created a SQL database and wrote a PHP script which accesses it. So far so good. ---------- The PHP script's URL is the following: https://starcaders.com/leaderboard.php ---------- As you can see, the PHP script is working and displays the table's entries (only two test entries atm). My goal is to read the text on the page and save it as a string in Unity. ---------- Unfortunately, the code below returns an empty string. The isDone bool is also false. ---------- I also tried to add a "SendWebRequest()" after yield return leaderboard, but that leads to the following error message: Curl error 51: Cert verify failed: UNITYTLS_X509VERIFY_FLAG_EXPIRED and also returns "hahaha TEST 123", my placeholder string. ---------- I also tried to retrieve text from other sites, but that returns an empty string as well. At this point, I am basically completely at a loss, which is why I created this thread. ---------- Thank you for your time, below you can see my code. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; // for UnityWebRequest public class Leaderboard : MonoBehaviour { void Start() { StartCoroutine("RequestLeaderboard"); } IEnumerator RequestLeaderboard() { UnityWebRequest leaderboard = UnityWebRequest.Get("http://starcaders.com/leaderboard.php"); //sends http request --> php script reads sql database yield return leaderboard; //waits until request is done string leaderboardString = "hahaha TEST 123"; if(!leaderboard.isNetworkError && !leaderboard.isHttpError) { leaderboardString = leaderboard.downloadHandler.text; } Debug.Log(leaderboardString); } }

How to use UnityWebRequest to upload a File via Invision REST API

$
0
0
Hello There I've been using UnityWebRequest to succesfully access some REST API endpoints. However when it comes to uploading files I couldn't get it to work and am wondering (this might be a bit of an open-ended question) what I am overlooking. I create a WWWForm like this, filling it with required parameters for the API request: WWWForm form = new WWWForm(); form.AddField("category", 6); form.AddField("title", "testing.txt"); form.AddField("description", "Just a file"); form.AddBinaryData("files", data, "testing.txt", "text/plain"); data is the byte array of the file im trying to upload. I then do a `UnityWebRequest.Post(url, form)` and set the request headers. However I always end up getting a "NO_FILES" response from the server (No files were supplied). Here's the documentation of the API-Endpoint I'm trying to access (with a short description of the files parameter and error codes): https://invisioncommunity.com/developers/rest-api?endpoint=downloads/files/POSTindex Instead of WWWForm, I've also tried using a List like this and received the same "NO_FILES" error from the server. List formData = new List(); formData.Add(new MultipartFormDataSection("category", "6")); formData.Add(new MultipartFormDataSection("title", "testing.txt")); formData.Add(new MultipartFormDataSection("description", "Just a file")); formData.Add(new MultipartFormFileSection("files", data, "testing.txt", "text/plain")); Thanks!

Webrequest Post SetRequestHeader Problem

$
0
0
Hi, im trying to POST json data to server using webrequest. It works in postman where two headers are added i.e content-type and access-token. but it throws 403 error in unity. Following is the code im using. I don't encounter any issue with content type application/json, but the custom header SetRequestHeader is not working. Please help me with this issue , Thanks in advance. private IEnumerator PostRequest(string url, string json, Action OnRequestProcessed) { var request = new UnityWebRequest(url, "POST"); byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json); request.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend); request.uploadHandler.contentType = "application/json"; request.SetRequestHeader("access-token", DBManager.Instance.playerToken); request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { Debug.LogError("web request error in Post method with responce code : " + request.responseCode); OnRequestProcessed(request.error, false); } else { OnRequestProcessed(request.downloadHandler.text, true); } request.Dispose(); }

UnityWebRequest in ScriptedImporter

$
0
0
I am writing an network asset importer to allow me to keep large assets out of my git repo, deduplicate assets, etc. I was wondering if it was possible to write a asynchronous file importer or even if not is it possible to run unity a UnityWebRequest synchronously. I can't start a coroutine in this content, and while I can start a task, attempting to wait for it to finish results in it never finishing, and it seems I can't write to context outside of `public override void OnImportAsset(AssetImportContext ctx)` (causes a crash) Any thoughts on if this is possible to do somehow. Thread.sleep causes hang, as does just looping. using UnityEngine; using UnityEditor.Experimental.AssetImporters; using System.IO; using UnityEngine.Networking; using System; using System.Threading; using System.Collections; using System.Threading.Tasks; [ScriptedImporter(1, "ipfs")] public class CubeImporter : ScriptedImporter { public float m_Scale = 1; public string uriStr; public Uri ipfsGateway = new Uri("http://localhost:8080"); public Texture2D debugTexture; private IEnumerator DoIt(AssetImportContext ctx, Uri uri) { using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(uri)) { var asyncOp = www.SendWebRequest(); yield return asyncOp; var texture = DownloadHandlerTexture.GetContent(www); ctx.AddObjectToAsset("main obj", texture); ctx.SetMainObject(texture); } } private async Task DoItAsync(AssetImportContext ctx, Uri uri) { using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(uri)) { var asyncOp = www.SendWebRequest(); while (asyncOp.isDone == false) { await Task.Delay(1000 / 30);//30 hertz } if (www.isNetworkError || www.isHttpError) { Debug.LogError($"{ www.error }, URL:{ www.url }"); return; } var texture = DownloadHandlerTexture.GetContent(www); Debug.Log($"{texture}, URL:{ www.url }"); debugTexture = texture; ctx.AddObjectToAsset("main obj", texture); ctx.SetMainObject(texture); } } public override void OnImportAsset(AssetImportContext ctx) { var ipfs = File.ReadAllText(ctx.assetPath); var uri = new Uri(ipfsGateway, ipfs); uriStr = uri.AbsoluteUri; var texture = new Texture2D(512, 512); var task = DoItAsync(ctx, uri); //task.Wait(); //ctx.AddObjectToAsset("main obj", texture); //ctx.SetMainObject(texture); //task.Wait(); // 'cube' is a a GameObject and will be automatically converted into a Prefab // (Only the 'Main Asset' is elligible to become a Prefab.) //var material = new Material(Shader.Find("Standard")); //material.color = Color.red; //// Assets must be assigned a unique identifier string consistent across imports //ctx.AddObjectToAsset("my Material", material); //// Assets that are not passed into the context as import outputs must be destroyed //var tempMesh = new Mesh(); //DestroyImmediate(tempMesh); } }

Translate cURL -d to Unity C# is throwing error 400 Bad Request

$
0
0
Hi, There's a web page where I want to make RESTful calls. However I am getting error 400 Bad Request. Testing from web page works just fine, however this error occurs only in unity. cURL: curl -X POST "http://MyWebSite.net/api/User/Authorize" -H "accept: text/plain" -H "Content-Type: application/json" -d "{\"userId\":\"i8PSadEvWAeOPFASfegE7sEPQPQO2\"}" And this is how I am translating this cURL command to unity C#: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; public class GameTest : MonoBehaviour { //I changed following url with some non-existent link, just for security reasons. public string url = "http://MyWebSite.net/api/User/Authorize"; // Start is called before the first frame update void Start() { StartCoroutine(PostRequest()); } IEnumerator PostRequest() { WWWForm form = new WWWForm(); //Uncommenting following line makes no difference //form.AddField("userId", "i8PSadEvWAeOPFASfegE7sEPQPQO2"); using (UnityWebRequest www = UnityWebRequest.Post(url, form)) { www.SetRequestHeader("accept", "text/plain"); www.SetRequestHeader("Content-Type", "application/json"); //Uncommenting following line makes no difference //www.SetRequestHeader("userId", "i8PSadEvWAeOPFASfegE7sEPQPQO2"); yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.LogError("ERROR: " + www.error); } else { Debug.Log("Success"); } } } } I believe that I am not sending -d "{\"userId\":\"i8PSadEvWAeOPFASfegE7sEPQPQO2\"}" correctly from unity. Any help is appreciated. Thanks

Checking correcly downloading asset bundle with web request.,Web Request and Asset Bundles

$
0
0
Is some way to check if correctly asset bundle was download from the server? Sometimes asset bundle not fully downloading, and content in it not fully visible.,Is can some way to check, that asset bundle was download correctly? Sometimes asset bundles not correctly downloading and all content aren't are fully visible.

Getting error while try to getting mp3 from dropbox link

$
0
0
Intention : want to make audio clip from dropbox link Error: Cannot create FMOD::Sound instance for clip "" (FMOD error: Unsupported file or audio format. ) UnityEngine.Networking.DownloadHandlerAudioClip:GetContent(UnityWebRequest) Code : IEnumerator GetAudioClip() { using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("https://www.dropbox.com/s/1a29u7f223k022w/sleep.mp3?dl=0", AudioType.MPEG)) { yield return www.SendWebRequest(); if (www.isNetworkError) { Debug.Log(www.error); } else { myClip1 = DownloadHandlerAudioClip.GetContent(www); audioSource.clip = myClip1; if (PlayerPrefs.GetInt(SettingMusic) == 0) { audioSource.clip = myClip1; audioSource.Play(); } else { audioSource.Stop(); } } } }

ERROR SAME REQUEST WITHIN A SECOND: 4

$
0
0
I am trying to upload a high score to dreamlo and am getting an error. "ERROR SAME REQUEST WITHIN A SECOND: 4 UnityEngine.MonoBehaviour:print(Object) HighScoreManager:FormatHighscores(String) (at Assets/Scripts/HighScoreManager.cs:68) d__10:MoveNext() (at Assets/Scripts/HighScoreManager.cs:52) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)" using System.Collections; using UnityEngine; using UnityEngine.Networking; public class HighScoreManager : MonoBehaviour { const string privateCode = ""; const string publicCode = ""; const string webURL = "http://dreamlo.com/lb/"; DisplayHighScore highscoreDisplay; public Highscore[] highscoresList; static HighScoreManager instance; void Awake() { highscoreDisplay = GetComponent(); instance = this; } public static void AddNewHighscore(string username, int score) { instance.StartCoroutine(instance.UploadNewHighscore(username, score)); } IEnumerator UploadNewHighscore(string username, int score) { WWW www = new WWW(webURL + privateCode + "/add/" + UnityWebRequest.EscapeURL(username) + "/" + score); yield return www; if (string.IsNullOrEmpty(www.error)) { print("Upload Successful"); DownloadHighscores(); } else { print("Error uploading: " + www.error); } } public void DownloadHighscores() { StartCoroutine("DownloadHighscoresFromDatabase"); } IEnumerator DownloadHighscoresFromDatabase() { WWW www = new WWW(webURL + publicCode + "/pipe/"); yield return www; FormatHighscores(www.text); highscoreDisplay.OnHighscoresDownloaded(highscoresList); } void FormatHighscores(string textStream) { string[] entries = textStream.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); highscoresList = new Highscore[entries.Length]; for (int i = 0; i < entries.Length; i++) { string[] entryInfo = entries[i].Split(new char[] { '|' }); string username = entryInfo[0]; int score = int.Parse(entryInfo[1]); highscoresList[i] = new Highscore(username, score); print(highscoresList[i].username + ": " + highscoresList[i].score); } } } public struct Highscore { public string username; public int score; public Highscore(string _username, int _score) { username = _username; score = _score; } } I have tried looking for a solution and have not found anything.
Viewing all 387 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>