using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System.Security.Cryptography.X509Certificates;
using System;
public class Calculation : MonoBehaviour
{
string jsonResult;
Helper.displayBoard[] displayInfo;
public Text E20, E40, E45;
public Text F20, F40, F45;
public Text T20, T40, T45;
// Use this for initialization
void Start()
{
E20 = GameObject.Find("E20").GetComponentInChildren<Text>();
E40 = GameObject.Find("E40").GetComponentInChildren<Text>();
E45 = GameObject.Find("E45").GetComponentInChildren<Text>();
F20 = GameObject.Find("F20").GetComponentInChildren<Text>();
F40 = GameObject.Find("F40").GetComponentInChildren<Text>();
F45 = GameObject.Find("F45").GetComponentInChildren<Text>();
T20 = GameObject.Find("T20").GetComponentInChildren<Text>();
T40 = GameObject.Find("T40").GetComponentInChildren<Text>();
T45 = GameObject.Find("T45").GetComponentInChildren<Text>();
StartCoroutine(LoadData());
//displydata();
}
// Update is called once per frame
void Update()
{
}
IEnumerator LoadData()
{
/* string contUrl = “http://961.8.144.142:9080/conslot/getContainerStatistics3d”;*/
string contUrl = “https://961.8.144.142:9080/conslot/getContainerStatistics3d”;
using (UnityWebRequest www = UnityWebRequest.Get(contUrl))
{
yield return www.Send();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
jsonResult = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data);
// Debug.Log(jsonResult);
jsonResult = jsonResult.Split(new string[] { "[" }, System.StringSplitOptions.None)[1];
jsonResult = jsonResult.Split(new string[] { "]" }, System.StringSplitOptions.None)[0];
displayInfo = Helper.JsonHelper.getJsonArray<Helper.displayBoard>(jsonResult);
foreach (Helper.displayBoard displayInf in displayInfo)
{
E20.text = displayInf.e20;
F20.text = displayInf.f20;
E40.text = displayInf.e40;
F40.text = displayInf.f40;
E45.text = displayInf.e45;
F45.text = displayInf.f45;
T20.text = (int.Parse(displayInf.e20) + int.Parse(displayInf.f20)).ToString();
T40.text = (int.Parse(displayInf.e40) + int.Parse(displayInf.f40)).ToString();
T45.text = (int.Parse(displayInf.e45) + int.Parse(displayInf.f45)).ToString();
}
}
}
}
}