Unity 3D Puts/Deletes http 方法 [英] Unity 3D Puts/Deletes http methods

查看:35
本文介绍了Unity 3D Puts/Deletes http 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将 JavaScript 网络应用程序移植到 C# Unity3D(免费/个人版),用于我正在开发的 RPG.我有一个内置于 PHP Laravel 5.1 的可扩展的独立 API,我的游戏通过 jQuery http 调用与之交互.

I'm thinking of porting a JavaScript web app to C# Unity3D (Free / Personal Version) for an RPG I'm developing. I have an extensible, separate API built in PHP Laravel 5.1, which my game interacts with through jQuery http calls.

我需要继续进行标准的restful调用,getpostputdelete等Unity 但只找到了 UnityEngine.WWW# 这使得 getsposts.

I need to continue making standard restful calls, get, post, put, delete, etc within Unity but have only found UnityEngine.WWW# which makes gets and posts.

此 SO Post 分享了其他可用的Unity3D http 方法,但实际上没有一个方法可以将所有安静的调用合二为一.我再次询问,因为这是在 2012 年 发布的,我在 更新文档.

This SO Post shares the other available Unity3D http methods, but none which actually get all restful calls in one. I'm asking again because this was posted in 2012 and I haven't found any updates which satisfy this within the updated documentation.

最佳HTTP基础最佳 HTTP 价格为 45 美元和 55 美元,但我认为还有其他免费选项.

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

我是否遗漏了 Unity 中允许标准宁静调用的内容?

Am I missing something within Unity that allows for standard restful calls?

推荐答案

WebClientWebRequest 都在 Unity 中可用,看起来它只适用于 Pro Unity 版本就像 System.Net 命名空间中的任何其他 API 一样.我不知道这个限制在 Unity 5 中是否有变化.他们支持你问题中提到的所有那些宁静的调用.

WebClient and WebRequest are both available in Unity and looks like it will only work with Pro Unity version just like any other API from the System.Net namespace. I don't know if this restriction has changed in Unity 5. They support all those restful calls mentioned in your question.

Unity 在 5.2 版中添加了一个名为 UnityWebRequest 的新 APIstrong> 在 5.3 中支持移动平台.它旨在替换 WWW 并支持您的问题中列出的所有 restfull 调用.下面是每个示例.这不是一个完整的例子.您可以在我上面提供的链接中找到完整的示例.

Unity Added a new API called UnityWebRequest in version 5.2 with mobile platform support in 5.3. It was designed to replace WWW and it supports all the restfull calls listed in your question. Below are example for each one. This is not a full example. You can find full examples in the link I provided 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");

您可以在此处查看每个示例的完整示例,包括使用 json 发布.

You can see complete example for each one including posting with json here.

这篇关于Unity 3D Puts/Deletes http 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆