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

Android HTTPS POST Request

$
0
0
I am having a heck of a time wrapping my head around the TLS handshake concept Unity Docs use this: using UnityEngine.Networking; using System.Security.Cryptography.X509Certificates; // Based on https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#.Net class RequestCertificate: CertificateHandler { // Encoded RSAPublicKey private static string PUB_KEY = "30818902818100C4A06B7B52F8D17DC1CCB47362" + "C64AB799AAE19E245A7559E9CEEC7D8AA4DF07CB0B21FDFD763C63A313A668FE9D764E" + "D913C51A676788DB62AF624F422C2F112C1316922AA5D37823CD9F43D1FC54513D14B2" + "9E36991F08A042C42EAAEEE5FE8E2CB10167174A359CEBF6FACC2C9CA933AD403137EE" + "2C3F4CBED9460129C72B0203010001"; protected override bool ValidateCertificate(byte[] certificateData) { X509Certificate2 certificate = new X509Certificate2(certificateData); string pk = certificate.GetPublicKeyString(); if (pk.Equals(PUB_KEY)) return true; // Bad dog return false; } } I am using a node / express server with a Letsencrypt certificate. I tried ```UnityWebRequest``` first. protected IEnumerator Register() { List wwwForm = new List(); wwwForm.Add(new MultipartFormDataSection("name", uName.text)); wwwForm.Add(new MultipartFormDataSection("email", uEmail.text)); wwwForm.Add(new MultipartFormDataSection("screenName", uScreenName.text)); wwwForm.Add(new MultipartFormDataSection("password", uConPass.text)); UnityWebRequest www = UnityWebRequest.Post(US_GameManager.API_URL + "users/store-user", wwwForm); www.certificateHandler = new RequestCertificate(); Debug.Log(www.certificateHandler); yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { debugText.text += " Error: " + www.error; } else { } } I get ```Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE``` Then I tried public void SendRegisterRequest(string endPoint, RegistrationRequestBody playerData) { var http = (HttpWebRequest)WebRequest.Create(US_GameManager.API_URL + endPoint); http.ContentType = "application/json"; http.Method = "POST"; string l_result = string.Empty; using (var streamWriter = new StreamWriter(http.GetRequestStream())) { string reqBody = JsonConvert.SerializeObject(playerData); streamWriter.Write(reqBody); streamWriter.Flush(); streamWriter.Close(); var response = (HttpWebResponse)http.GetResponse(); using (var streamReader = new StreamReader(response.GetResponseStream())) { l_result = streamReader.ReadToEnd(); debugText.text += $"SendRegisterRequest() {l_result} \n"; } } m_regRes = (RegistrationResponseBody)DSRegistraionResponse(l_result); debugText.text += $" m_regRes: {m_regRes} route: {US_GameManager.API_URL }{m_endPoint} \n"; Debug.Log("Reg Res: " + m_regRes.Message); // response body status == 200 if (m_regRes.Status == 200) { sceneManager.SetUserId(m_regRes.userId); print("RES userId: " + m_regRes.userId); debugText.text += $" m_regRes: {m_regRes} route: {m_endPoint} \n"; Player.name = m_regRes.name; Player.userId = m_regRes.userId; Player.screenName = m_regRes.screenName; Player.scores = m_regRes.scores; Player.lastScenePlayed = m_regRes.lastScenePlayed; Player.friendsList = m_regRes.friendsList; Player.isLoggedIn = true; PlayerPrefs.SetString("userID", m_regRes.userId); //sceneManager.LoadScene(2); // Registration successful => load lobby } } And to make matters worse this code makes it to the same API public async void CheckEmailExists(string email) { //Debug.Log("SceneManager.GetUserById() UserId exists"); try { HttpResponseMessage response = await client.GetAsync(US_GameManager.API_URL + checkEmailRoute + email); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); print($"Found Email: {responseBody}"); if (responseBody == "200") { emailExistsError.gameObject.SetActive(true); } } catch (HttpRequestException e)// 404 rout not found because there is no UserId stored on device { Debug.Log(e); } } With the same result. One thing that throws me is when is ```RequestCertificate.ValidateCertificate()``` being called? Any and all help is greatly appreciated. @jdnichollsc @GuiiDo

How to upload/PUT to a GitHub repository while playing

$
0
0
I know this question is very broad and I cannot supply any coding attempts. However I have been diligently searching the web for a solution to my problem. How do I upload data onto a GitHub repository in a Unity BUILT Game? I have read about the UnityWebRequest.Put. However attempting to send data to the Github repository URL doesn't work. Is there a way to authenticate my Unity App to GET and PUT data on a GitHub Repository that I own? Thank you for your help.

Unity user authorization API with return value,Unity, app needs user's authorization which returns an api key

$
0
0
What I need the app to do is to send a user over to a link with some parameters, like the ID of my app, what I want the response from the API to be. I achieved this with Application.Url(url);. The user then can authorize the apps permission to access this users account and stuff, so he can post on forum or chat with his username, like he would do in-game. BUT! After the authorization from the user, the api returns a user specific api key that I need the app to further use. But I don't know how to do this. Using UnityWebRequest won't let the user click on the authorization button but Application.Url(); won't return any value from the web page.
Does anyone have a way to do this ? I'm sure there is a way, but I can't think of anything rn.

Download pdf file form url and saving in the specific folder in the mobile.

$
0
0
I had implemented using "Application.openurl()" and it automatically downloading .pdf file, but it is redirecting to browser. which shouldn't happen. My scenario is, downloading pdf file and save in specific folder or in downloads folder in mobile with out opening browser. I haven't find any solution from google . Is there anyway to do it?

DropBox Https Api Request : What should I do?

$
0
0
Hello everyone. I'm going crazy with DropBox Api Http Never used an Api Call and don't know how to manage it. **What should I Do :** 1. Get access to my Public Folder 2. Find Sharable Link for images **My Question** How should be the script to "send the request"? (can't figure out ...) (need a full script) How should be the "response" and how I should deserialize it (JsonUtily?) Thank you a lot. For now I only figured out that I should use WebRequest (but I don't know how). Already configured DropBox App and I have the Token. From here and on I cannot understand what I should do...

web request hangs up in unity

$
0
0
Hi! I am trying to wirelessly control an IP camera (ricoh theta z1) in my Unity app. At the very beginning, I tried the **HttpWebRequest** and the script looks like this: public class ThetaWifiStreaming : MonoBehaviour { public static string ToString(string cmd) { var sb = new StringBuilder(); sb.Append("{"); sb.Append("\"name\": \""); sb.Append(cmd); sb.Append("\", \"parameters\": {"); sb.Append("}}"); return sb.ToString(); } static void start() { var command = ToString("camera.takePicture"); var postBytes = Encoding.Default.GetBytes(command); string url = "http://192.168.12.21:80/osc/commands/execute"; string username = "THETAYN10106522"; string password = "10106522"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Credentials = new NetworkCredential(username, password); Console.WriteLine(new NetworkCredential(username, password)); request.Method = "POST"; request.Timeout = (int)(5 * 1000f); request.ContentType = "application/json;charset=utf-8"; request.ContentLength = postBytes.Length; Stream reqStream = request.GetRequestStream(); reqStream.Write(postBytes, 0, postBytes.Length); reqStream.Close(); Console.WriteLine("post done"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Console.WriteLine((int)response.StatusCode); Console.WriteLine("response done"); } } This script works well if I copy and paste the main body of this script and run it as a new ordinary c# console app. But in unity, it will be stuck at the **post done** sentence and cannot get any responses (the status code cannot be received). Would anybody give me some suggestions on how to do it? Thanks!

I get this error when doing webrequest

$
0
0
Hi, I open my project this morning, it was working fine but all of sudden.. I get this error message from the same coroutine Curl error 51: Cert verify failed: UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH Can someone help me on this? I tried google but I can't find the same error message. Thank you

List suddenly auto-clear after WebRequest (in another Script)?

$
0
0
Hi at all. Strange issue happen. **I've implemented a small call WebRequest to Api DropBox** ([check here the final solution i've found][1]) [1]: https://answers.unity.com/questions/1796779/dropbox-https-api-request-what-should-i-do.html Now I'm in trouble with a strange issue : **I've declared a List . But after returning from WebRequest (it is in another Script) suddenly List.Count become = 0.** I've checked carefully all calls, but in noways this "List" is touched... but it will lost after WebRequest. Not sure but I'm believe **that I should find a "way" to keep it in memory (but don't know how).** private void Loader() { // Copy a Photo List from Shared Variables for (int i = 0; i< VideoGames_SharedVar.PhotoList.Count; i++) { PhotoListDropBox.Add(VideoGames_SharedVar.PhotoList[i]); } // Path per DropBox DropBoxImagePath = ""; DropBoxLoadDone=false; } private IEnumerator ImageParse() { DropBoxFullLoad=false; // Go Thru all Images for (int i = 0; i < PhotoListDropBox.Count; i++) { // Processing Url for WebRequest string[] StringArray = PhotoListDropBox[i].Split(new string[] {"\\"}, StringSplitOptions.None); DropBoxImagePath = StringArray[StringArray.Length-1]; DropBoxImagePath = "/Shared Folder/" + DropBoxImagePath; // Call WebRequest on another script WebRequestScript.PressMe(); // Wait until loading from Webrequest is done (list count is OK) while (DropBoxLoadDone==false) { yield return null; }; // HERE MY LIST BECAME ZERO string TempString = CercaSharedURL(); PhotoListDropBox[i] = TempString; // Above error is generated because PhotoListDropBox is null } DropBoxFullLoad=true;

unitywebrequest and ARFoundation In IOS device get stuck randomly

$
0
0
trying to download Asset bundle from server using unitywebrequest, sometimes it is unable to download manifest file randomly, and can't able to connect the server for further until kill the app in mobile. Here I am using Arfoundation in the app Same code working fine in Android and webgl, getting issue only in ios. Please help me in this. Here is my code IEnumerator DownloadAssetBundleFromServerCallFunc () { UnityWebRequest manifestWebRequest = UnityWebRequest.Get(url + ".manifest"); yield return manifestWebRequest.SendWebRequest(); while (!manifestWebRequest.isDone) { yield return null; } string manifestString = manifestWebRequest.downloadHandler.text; Hash128 hash = Hash128.Compute((Random.value * int.MaxValue).ToString()); foreach (string line in manifestString.Split('\r', '\n')) { if (line.StartsWith(" Hash: ")) { try { hash = Hash128.Parse(line.Substring(9)); Debug.Log("Successfully parsed hash. Value is " + hash + "."); } catch { Debug.LogError("Error when parsing hash; skipping parse and forcing download."); } break; } } Debug.Log("Downloading from " + url + "..."); UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url, hash); StartCoroutine(DownloadBarProgress(www)); yield return www.SendWebRequest(); while (!www.isDone) { yield return null; } if (myLoadedAssetBundle != null) { myLoadedAssetBundle.Unload(true); //scene is unload from here if (www.error == null) { myLoadedAssetBundle = DownloadHandlerAssetBundle.GetContent(www); } } }

Texture from web is not working on shader?

$
0
0
Hi. I'm working on masking shader which download mask texture from www. Here is my code snippet. var request = UnityWebRequestTexture.GetTexture(url); await request.SendWebRequest(); var maskTexture = DownloadHandlerTexture.GetContent(request); mat.SetTexture("Texture2D_76EB197C", maskTexture ); and here is my shader graph. ![alt text][1] It's very weird because only imported texture is working. ![alt text][2] There is one difference that format of texture from www is ARGB and from imported is RGB. But I didn't use alpha channel in my shader. This is texture from www ![alt text][3] and here is imported texture ![alt text][4] Can anyone tell me why and how to fix this issue. Thanks for in advance. [1]: https://i.imgur.com/c7Y0rdJ.png [2]: https://i.imgur.com/h7zoDcZ.png [3]: https://i.imgur.com/2lcn3M2.png [4]: https://i.imgur.com/xqsZCHa.png

How do I retrieve a binary file with UnityWebRequest?

$
0
0
I'm building a game for WebGL. My main goal is to save and load data from a binary file from my StreamingAssets folder. --------- I've read the documentation that says that I need to use UnityWebRequest for that, but it really doesn't explains anything.. ----------- I mostly don't understand how do I de-serialize my binary file and then serialize it again and use a web request to save it back. Can I access it from UnityWebRequest.downloadHandler?

Error: HTTP/1.1 405 Method Not Allowed

$
0
0
When I try to use UnityWebRequest.Put() I get the error aforementioned. ------ I am hosting my game on HostGator. I've asked their tech support but they have no idea and they say I should consult with a Web Developer. So instead I'm consulting with this amazing community. --- I want to state that my initial plan was to use UnityWebRequest.Post(), but I can't find a way to send byte[] through this function. It is only possible to do so with the UnityWebRequest.Put() function. --- This is the part of my code where I try to upload a new binary file: public static PlayerData[] OldPlayersData; public static IEnumerator SavePlayer(PlayerData player) { byte[] finalDataToSend; PlayerData[] newData = new PlayerData[] { player }; newData = newData.Concat(OldPlayersData); BinaryFormatter bf = new BinaryFormatter(); using (MemoryStream ms = new MemoryStream()) { bf.Serialize(ms, newData); finalDataToSend = ms.ToArray(); } UnityWebRequest www = UnityWebRequest.Put(putPlayersURL, finalDataToSend); yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.LogError(www.error); } else { Debug.Log("done"); } } --- **Bottom line, my questions are:** 1. Is there a way to make this method allowed? If not, is there a work-around? 2. Is there really no way to send byte[] data through UWR.Post()? 3. Please help my solve this in any other way. This is crucial to me.

Fatal Exception when loading multiple image files on Android from persistent data path

$
0
0
I'm having trouble to solve a Fatal Exception that is occurring when trying to load multiple .png files from my android persistent data path using Unity Web Request. The coroutine that does the image loading is this: IEnumerator DoLoadSpriteFromLocal(string p_loadPath, int p_loadID, T p_object, Action p_callback) { string __loadPath = p_loadPath; #if UNITY_ANDROID __loadPath = $"file://{__loadPath}"; #endif UnityWebRequest __uwr = UnityWebRequestTexture.GetTexture(__loadPath); var __operation = __uwr.SendWebRequest(); float __timer = 0; while(!__operation.isDone) { yield return null; __timer += Time.deltaTime; if (__timer >= _timeoutTime) { break; } } if (__operation.isDone) { if (__uwr.isHttpError || __uwr.isNetworkError) { p_callback(false, $"Load sprite failed. \nLoad sprite path: {__loadPath} \nLoad sprite error: \n{__uwr.error}", p_loadID, p_object, null); } else { Texture2D __texture = DownloadHandlerTexture.GetContent(__uwr); Sprite __sprite = Sprite.Create(__texture, new Rect(0, 0, __texture.width, __texture.height), new Vector2(0.5f, 0.5f)); p_callback(true, $"Load sprite success. \nLoad sprite path: {__loadPath}", p_loadID, p_object, __sprite); } } else { p_callback(false, $"Load sprite timeout. \nLoad sprite path: {__loadPath}", p_loadID, p_object, null); } } To load the images I start one of this coroutine for each one of the image files that I want to load. Then, after some loading the Android closes the game and point out a Fatal Exception with the following message: 01-20 13:40:00.689: E/AndroidRuntime(24907): FATAL EXCEPTION: UnityMain 01-20 13:40:00.689: E/AndroidRuntime(24907): Process: com.DefaultCompany.IndieWrestler, PID: 24907 01-20 13:40:00.689: E/AndroidRuntime(24907): java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 01-20 13:40:00.689: E/AndroidRuntime(24907): Version '2019.4.11f1 (2d9804dddde7)', Build type 'Development', Scripting Backend 'mono', CPU 'armeabi-v7a' 01-20 13:40:00.689: E/AndroidRuntime(24907): Build fingerprint: 'Xiaomi/platina/platina:10/QKQ1.190910.002/V12.0.3.0.QDTMIXM:user/release-keys' 01-20 13:40:00.689: E/AndroidRuntime(24907): Revision: '0' 01-20 13:40:00.689: E/AndroidRuntime(24907): ABI: 'arm' 01-20 13:40:00.689: E/AndroidRuntime(24907): Timestamp: 2021-01-20 13:39:53-0300 01-20 13:40:00.689: E/AndroidRuntime(24907): pid: 24907, tid: 24998, name: UnityGfxDeviceW >>> com.DefaultCompany.IndieWrestler <<< 01-20 13:40:00.689: E/AndroidRuntime(24907): uid: 10540 01-20 13:40:00.689: E/AndroidRuntime(24907): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 01-20 13:40:00.689: E/AndroidRuntime(24907): Cause: null pointer dereference 01-20 13:40:00.689: E/AndroidRuntime(24907): r0 00000000 r1 4def3630 r2 00f42300 r3 00000000 01-20 13:40:00.689: E/AndroidRuntime(24907): r4 4def3610 r5 00000001 r6 00000000 r7 00000000 01-20 13:40:00.689: E/AndroidRuntime(24907): r8 00000000 r9 00000000 r10 000007d0 r11 000007d0 01-20 13:40:00.689: E/AndroidRuntime(24907): ip ed33cc50 sp b7306bb0 lr c1082098 pc ed2e256c 01-20 13:40:00.689: E/AndroidRuntime(24907): backtrace: 01-20 13:40:00.689: E/AndroidRuntime(24907): #00 pc 0005e56c /apex/com.android.runtime/lib/bionic/libc.so (__memcpy_base_a55+244) (BuildId: 18716d52b3e361e6d51e50b6e66c16d5) 01-20 13:40:00.689: E/AndroidRuntime(24907): #01 pc 009f5094 /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (vk::ImageManager::UploadThreaded(vk::ScratchBufferAllocation, dynamic_array&, vk::Image*, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, TextureFormat, TextureColorSpace, int, unsigned int)+500) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #02 pc 009f437c /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (vk::ImageManager::Upload(vk::CommandBuffer*, vk::ScratchBuffer*, vk::Image*, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, TextureFormat, TextureColorSpace, int, unsigned int)+388) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #03 pc 009f419c /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (vk::ImageManager::CreateImage(vk::CommandBuffer*, vk::ScratchBuffer*, TextureDimension, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, TextureFormat, TextureColorSpace, int, unsigned int, VkSampleCountFlagBits, bool)+792) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #04 pc 009a0188 /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (vk::Texture::Create(vk::CommandBuffer*, vk::ScratchBuffer*, TextureID, TextureDimension, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, int, VkSampleCountFlagBits, bool, bool)+460) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #05 pc 009a0980 /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (GfxDeviceVK::UploadTexture2D(TextureID, TextureDimension, unsigned char const*, int, int, int, GraphicsFormat, int, TextureUploadFlags, TextureUsageMode)+264) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #06 pc 0036d34f /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)+6854) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #07 pc 003724b7 /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)+26) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #08 pc 0037247d /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (GfxDeviceWorker::Run()+96) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #09 pc 0036b647 /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (GfxDeviceWorker::RunGfxDeviceWorker(void*)+2) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #10 pc 007f563f /data/app/com.DefaultCompany.IndieWrestler-cNSHuzzHr165gLQPt0pCOA==/lib/arm/libunity.so (Thread::RunThreadWrapper(void*)+342) (BuildId: b554bd08ed514ed0bf8d653470ba6bfaeed63263) 01-20 13:40:00.689: E/AndroidRuntime(24907): #11 pc 000aa8bb /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: 18716d52b3e361e6d51e50b6e66c16d5) 01-20 13:40:00.689: E/AndroidRuntime(24907): #12 pc 000619b3 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: 18716d52b3e361e6d51e50b6e66c16d5) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libc.__memcpy_base_a55(__memcpy_base_a55:244) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.vk::ImageManager::UploadThreaded(vk::ScratchBufferAllocation, dynamic_array&, vk::Image*, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, TextureFormat, TextureColorSpace, int, unsigned int)(UploadThreaded:500) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.vk::ImageManager::Upload(vk::CommandBuffer*, vk::ScratchBuffer*, vk::Image*, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, TextureFormat, TextureColorSpace, int, unsigned int)(Upload:388) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.vk::ImageManager::CreateImage(vk::CommandBuffer*, vk::ScratchBuffer*, TextureDimension, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, TextureFormat, TextureColorSpace, int, unsigned int, VkSampleCountFlagBits, bool)(CreateImage:792) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.vk::Texture::Create(vk::CommandBuffer*, vk::ScratchBuffer*, TextureID, TextureDimension, vk::ImageData const&, VkExtent3D const&, GraphicsFormat, int, VkSampleCountFlagBits, bool, bool)(Create:460) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.GfxDeviceVK::UploadTexture2D(TextureID, TextureDimension, unsigned char const*, int, int, int, GraphicsFormat, int, TextureUploadFlags, TextureUsageMode)(UploadTexture2D:264) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)(RunCommand:6854) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)(RunExt:26) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.GfxDeviceWorker::Run()(Run:96) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.GfxDeviceWorker::RunGfxDeviceWorker(void*)(RunGfxDeviceWorker:2) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libunity.Thread::RunThreadWrapper(void*)(RunThreadWrapper:342) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libc.__pthread_start(void*)(__pthread_start:20) 01-20 13:40:00.689: E/AndroidRuntime(24907): at libc.__start_thread(__start_thread:30) There does not seem to be a pattern to when the Android will show this exception since the point at which he stops the game can vary (some times the game will run without any problems, but in the majority of times it will occur the exception). I tried to use File.ReadAllBytes but the same exception appears. If someone have a hint to where is the problem in my game would be of a great help!

How to replace WWW to UnityWebRequest

$
0
0
using Dummiesman; using System.IO; using System.Text; using UnityEngine; public class ObjFromStream : MonoBehaviour { void Start () { //make www var www = new WWW("https://people.sc.fsu.edu/~jburkardt/data/obj/lamp.obj"); while (!www.isDone) System.Threading.Thread.Sleep(1); //create stream and load var textStream = new MemoryStream(Encoding.UTF8.GetBytes(www.text)); var loadedObj = new OBJLoader().Load(textStream); } }

Not able to download the same file simultaneously

$
0
0
I have started two coroutines to download two gifs, if the gif urls are different everything is fine. If I pass same urls second coroutine is not unpausing. Can we not download same file at same time? UnityWebRequest www = new UnityWebRequest(path) { downloadHandler = new DownloadHandlerBuffer() }; yield return www.SendWebRequest();

communication between unity and browser using webRTC

$
0
0
I have a question about the communication between unity and the browser using webRTC. I would like to have another computer B in addition to computer A running unity, and I would like to move objects in unity on computer A by mouse or keyboard operation from the browser on computer B. (I don't want to use unity to unity communication or remote desktop, because I want to accept operations from a third party who doesn't have unity installed.) I understand from [this page][1] that sending the camera scene in unity running in A to B's browser is possible using Unity Render Streaming. However, from the video in the link, does that mean that the only thing that can be done from the browser is to change the perspective of the camera? Also, if there is a library that can do what I'm thinking of, I would appreciate it if you could let me know. I'm afraid my English is not very good, so I apologize if I don't communicate well. [1]: https://docs.unity3d.com/Packages/com.unity.renderstreaming@2.0/manual/jp/index.html

How do I add a header and a file at the web request at the same time?

$
0
0
Hello, I am having some issues sending files over the server. I have a few different types of calls I need to make to the server. One is send a file, one send a string with a custom header and one send file with a custom header. The first two options work fine, but I am having troubles with the last one. Examples of working code, sending a file: WWWForm form = new WWWForm(); form.AddBinaryData("file", scene, "save.txt", "text/plain"); WWW www = new WWW(url, form); yield return www; Working if I just send a json string over with a header: UnityWebRequest webRequest = new UnityWebRequest(url, "POST"); webRequest.SetRequestHeader("Content-Type", "application/json"); webRequest.SetRequestHeader("Authorization", GetAuthorizationHeader()); webRequest.uploadHandler = new UploadHandlerRaw(Encoding.ASCII.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(GetData()))); webRequest.downloadHandler = new DownloadHandlerBuffer(); webRequest.SendWebRequest(); However, if I want to send a file with a header, I just get various errors, depending on how I try to send that file. (simplifying code later not to make a wall of text, if needed I can edit the code in later) As WWWForm does not allow to add headers, changing WWW call to WWW(path, form.data, headers) gives errors like "not a multipart form" or "no multipart boundary found" WWW(path, form.data + boundary, headers) give error "Required request part 'file' is not present" Trying to send it with UnityWebRequest gives the same errors. Can anyone explain how I should do this?

,Convert Curl command with wav file to Unity web request

$
0
0
,Currently trying to convert a curl command to Unity Web request Curl Command: curl -H “x-app-key:APP_KEY_HERE“ / -F " file=@AudioFile.wav" / -F "user_token=USER_TOKEN_HERE" / -F "category=orange" / https://api.soapboxlabs.com/v1/speech/verification And the code I've attempted: private string url = "https://api.soapboxlabs.com/v1/speech/verification"; private string apiKey = "123456789"; void Start() { StartCoroutine(MakeSoapboxRequest()); } IEnumerator MakeSoapboxRequest() { List form = new List { new MultipartFormFileSection("file", "Assets\\Pilot1\\Audio\\soapbox_test.wav"), new MultipartFormDataSection("user_token", "aaa1234567"), new MultipartFormDataSection("category", "orange") }; /* WWWForm form = new WWWForm(); form.AddField("file", "@Assets\\Pilot1\\Audio\\soapbox_test.wav"); form.AddField("user_token", "abc123"); form.AddField("category", "orange");*/ UnityWebRequest request = UnityWebRequest.Post(url, form); request.SetRequestHeader("x-app-key", apiKey); yield return request.SendWebRequest(); if(request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else { Debug.Log("No soapbox error"); Debug.Log(request.downloadHandler.text); } } Keep getting an error HTTP/1.1.400 Bad request As you can see I've tried and commented out, WWW form as well. Is it something to do with me sending the wav file? I've tried looking into sending it as bytes but was left confused. The API I'm sending it to only takes wav files. It returns a JSON file. I'm just using the downloadHandler.text as a test. Any help would be appreciated. I haven't used CURL before and it's my first time trying Unity Web Requests.

How can I load an AudioClip from a local audio file using UnityWebRequests?

$
0
0
I'm trying to make a rhythm game which allows for creation of custom levels. To accomplish this, I need to be able to load audio files from local folders. I can't use the Resources folder because the user needs to be able to provide the song file themselves during level development. I've been using the following method: string songPath = "C:\Users\...\levels\[level name]\song.ogg" using (var www = new WWW("file:///" + songPath)) { yield return www; song = www.GetAudioClip(); } audioSource.clip = song; It's been working well, but the console gives me a warning saying that WWW is obsolete, and I should be using UnityWebRequests. I'd like to, to futureproof my game, but I can't figure out how to do it. How can I use UnityWebRequests to extract an AudioClip from a local audio file?

WWWForm not posting variables

$
0
0
I have this working just fine in one project however in a second project my _POST variables are blank. Thoughts? IEnumerator GetClub() { Debug.Log("GetClub: - START"); WWWForm form = new WWWForm(); form.AddField("state", "TX"); form.AddField("author", "MYNAME"); UnityWebRequest res = UnityWebRequest.Post(getGlubsURL, form); yield return res.SendWebRequest(); Debug.Log(res.downloadHandler.text); and the php file is a simple and console in unity is: HERE author: [] state: [] UnityEngine.Debug:Log (object)
Viewing all 387 articles
Browse latest View live


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