初学hololens,教程Acadmy 101的例子中的手势部分给球体加了刚体,本人按照下方教程在其后加入了一段HTTP请求(POST),但并没有work,不知道错误原因 请大神们赐教指导。PS:用hololens自带的浏览器可以访问的请求的链接。
https://docs.unity3d.com/Manual/UnityWebRequest-HLAPI.html
代码如下:
void OnSelect()
{
// If the sphere has no Rigidbody component, add one to enable physics.
if (!this.GetComponent<Rigidbody>())
{
var rigidbody = this.gameObject.AddComponent<Rigidbody>();
rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
}
// send HTTP request to the servlet
Upload();
}
IEnumerator Upload()
{
WWWForm form = new WWWForm();
form.AddField("myField", "x+");
UnityWebRequest www = UnityWebRequest.Post("http://172.31.70.233:8080/HOLO05/HoloServlet", form);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
}