-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendData2Server_v1.cs
More file actions
38 lines (32 loc) · 984 Bytes
/
SendData2Server_v1.cs
File metadata and controls
38 lines (32 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using UnityEngine.UI;
public class SendData2Server_v1 : MonoBehaviour
{
public Button PostBucketButton = null;
void Start()
{
PostBucketButton.onClick.AddListener(() => { PostObject(); });
}
void PostObject()
{
StartCoroutine(Upload());
}
IEnumerator Upload()
{
//byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data");
string myData = "This is some test data";
//UnityWebRequest www = UnityWebRequest.Put("http://www.my-server.com/upload", myData);
UnityWebRequest www = UnityWebRequest.Put("http://localhost:80/", myData);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Upload complete!");
}
}
}