Unity 3D installs / removes http methods

I am going to port a JavaScript web application to C # Unity3D (free / personal version) for the RPG I am developing. I have an extensible standalone API built into PHP Laravel 5.1 that my game interacts with using jQuery http calls.

I need to continue making standard soothing calls get , post , put , delete , etc. in Unity, but only found UnityEngine.WWW# , which does gets and posts .

This Post post uses other available Unity3D http methods, but none of them actually calls all the other calls in one. I ask again, because it was published in 2012 , and I did not find updates that satisfy this in the updated documentation .

There is Best HTTP Basic and Best HTTP for $ 45 and $ 55, but I thought there would be other free options.

Am I missing something in Unity that allows you to make standard soothing calls?

+4
source share
1 answer

WebClient and WebRequest are available in Unity and seem to work only with the Pro Unity version, like any other API from the System.Net namespace. I donโ€™t know if this restriction has changed in Unity 5. They support all these soothing calls mentioned in your question.

Unity Added a new API called UnityWebRequest in version 5.2 with support for the 5.3 mobile platform. It was designed to replace WWW and supports all other calls listed in your question. Below are examples for each of them. This is not a complete example. You can find complete examples in the link above.

 //Get UnityWebRequest get = UnityWebRequest.Get("http://www.myserver.com/foo.txt"); //Post UnityWebRequest post = UnityWebRequest.Post("http://www.myserver.com/foo.txt","Hello"); //Put byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data"); UnityWebRequest put = UnityWebRequest.Put("http://www.my-server.com/upload", myData); //Delete UnityWebRequest delete = UnityWebRequest.Delete("http://www.myserver.com/foo.txt"); 

You can see a complete example for everyone, including posting with json here .

+7
source

Source: https://habr.com/ru/post/1266492/


All Articles