using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; public class EMGNew : MonoBehaviour { private string EMGValString; private string particleURI; public InstructionManager instructionManager; IEnumerator GetEMGValue() { while (true) { // Assign your URI here particleURI = "https://api.particle.io/v1/devices/[Insert your device id]/Next?access_token=[Insert your access token]"; // Create a GET web request UnityWebRequest EMGStateRequest = UnityWebRequest.Get(particleURI); // Wait until the data has been received yield return EMGStateRequest.SendWebRequest(); // Make sure you have JSON Object plugin imported JSONObject EMGData = new JSONObject(EMGStateRequest.downloadHandler.text); // Open the URI link and you can see the value you want is stored in "result", grab this data and store EMGData = EMGData["result"]; // Convert the JSON object to a string EMGValString = EMGData.ToString(); if (EMGValString != "\"false\"") { //For my project, this is the call that interacts with the HUD instructionManager.NextStep(); } // delay 1 second yield return new WaitForSeconds(0); } } void Start() { StartCoroutine(GetEMGValue()); } void Update() { } }