Hello everyone.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Get JSON Data from server. - Unity Project
Hey,
- Developing on Unity -
I am trying to get some data from the server. Accessing the server via a URL. I have also checked the 'Internet Client' and 'Internet Client Server' capabilities, still the data is not getting downloaded. Here is the script attached to one of the Game Objects.
using System.Collections;
using System;
public class Http : MonoBehaviour
{
/* * Add all objects here */ public static Image goodPacksDialScript; public static Text goodPacksTextScript; public static Text badPacksTextScript; public static Image upTimeDialScript; public static Text upTimeTextScript; public static Text downTimeTextScript; public static Text performaceTextScript; public static Text throughputTextScript; public static Text logTextScript; public static Text speedTextScript; public static float goodPacksPercentage; public static Text goodPacksPercentageText; // Inner data public string url = "http://test-225410.nitrousapp.com:4000/cur_data"; private Data data; public class Data { public string[] data; } void Start() { // setup refs goodPacksDialScript = GameObject.Find("GPDial").GetComponent<Image>(); goodPacksTextScript = GameObject.Find("GPCount").GetComponent<Text>(); badPacksTextScript = GameObject.Find("BPCount").GetComponent<Text>(); goodPacksPercentageText = GameObject.Find ("GPPercentage").GetComponent<Text> (); upTimeDialScript = GameObject.Find("UTDial").GetComponent<Image>(); upTimeTextScript = GameObject.Find("UTCount").GetComponent<Text>(); downTimeTextScript = GameObject.Find("DTCount").GetComponent<Text>(); performaceTextScript = GameObject.Find("PerScore").GetComponent<Text>(); throughputTextScript = GameObject.Find("TPCount").GetComponent<Text>(); logTextScript = GameObject.Find("LSCount").GetComponent<Text>(); speedTextScript = GameObject.Find("SpeedCount").GetComponent<Text>(); // call updater StartCoroutine(UpdateValues()); } IEnumerator Request() { Debug.Log("Requesting values"); WWW www = new WWW(url); yield return www; if (www.error != null) { print("There was an error getting the data: " + www.error); yield break; } string json = www.text; data = JsonUtility.FromJson<Data>(json); //for (int i = 0; i < data.data.Length; i++) //{ // Debug.Log(data.data[i]); //} goodPacksDialScript.fillAmount = (float)(Int32.Parse(data.data[4]) / (float)Int32.Parse(data.data[6])); goodPacksTextScript.text = data.data[4]; badPacksTextScript.text = data.data[5]; goodPacksPercentage = (float)(Int32.Parse (data.data [4])) / ((float)(Int32.Parse (data.data [4])) + (float)(Int32.Parse (data.data [5]))) * 100; goodPacksPercentageText.text = Math.Round (goodPacksPercentage, 0).ToString()+"%"; upTimeDialScript.fillAmount = (float)(Int32.Parse(data.data[7]) / ((float)Int32.Parse(data.data[7]) + Int32.Parse(data.data[8]))); upTimeTextScript.text = data.data[7]; downTimeTextScript.text = data.data[8]; throughputTextScript.text = data.data[9]; logTextScript.text = data.data[3]; speedTextScript.text = data.data[10]; } IEnumerator UpdateValues() { while (true) { StartCoroutine(Request()); yield return new WaitForSeconds(5); } } // Update is called once per frame void Update() { }
}
Can anyone help ?
Tagged:
0
Answers
The url is wrong, at least it seems. Pasting it in a browser gives a Server not accessible page.