Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public void LightColor(string newColorHue)
  2. {
  3. string lightApiNumber = PlayerPrefs.GetString("lightapinumber");
  4. string onBodyCommandColorHue = "{\"hue\": " + newColorHue +",\"bri\": 254, \"sat\": 254}";
  5.  
  6. StartCoroutine(ChangeColor());
  7. IEnumerator ChangeColor()
  8. {
  9. byte[] myData = System.Text.Encoding.UTF8.GetBytes(onBodyCommandColorHue);
  10. Debug.Log("Dentro de LightColor esta llegando el color: "+newColorHue);
  11. using (UnityWebRequest www = UnityWebRequest.Put("http://" + PlayerPrefs.GetString("bridgeip") + "/api/" + PlayerPrefs.GetString("username") + "/lights/" + lightApiNumber + "/state", myData))
  12. {
  13. yield return www.Send();
  14.  
  15. if (www.isNetworkError || www.isHttpError)
  16. {
  17. Debug.Log(www.error);
  18. }
  19. else
  20. {
  21. Debug.Log("completado");
  22. }
  23. }
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement