using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class PhotonController : MonoBehaviour
{
bool ledIsOn = false;
bool callOnce = false;
void Start()
{
}
public IEnumerator Upload(string state)
{
WWWForm form = new WWWForm();
form.AddField("arg", state);
using (UnityWebRequest www = UnityWebRequest.Post("https://api.particle.io/v1/devices/3d0017000751373238323937/play?access_token=77eb52ce2e1beb7e1d527da80c1e4239616ceb7c", form))
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
}
private void Update()
{
if (LanternController.startFlying)
{
if (!ledIsOn && !callOnce)
{
StartCoroutine(Upload(""));
callOnce = true;
}
}
}
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .