// Update is called once per frame void Update() { int index = -1; while (WSNetworkManager.FFQueue.Count > 0) { string instruction = WSNetworkManager.FFQueue.Dequeue(); if (instruction.Contains("Destroy")) { Destroy(FFList[index]); FFList.RemoveAt(index); } else { FF n = JsonUtility.FromJson <FF>(instruction); index = FFList.FindIndex(FF => FF.GetComponent <CircleData>().id == n.id); if (index >= 0) { // Object already in list var ffpos = FFList[index].GetComponent <CircleData>(); var m = Panel.GetComponent <LocationController>(); ffpos.lng = n.lon; ffpos.lat = n.lat; ffpos.alt = n.alt; ffpos.tmp = n.temp; ffpos.time = n.time; ffpos.humidity = n.humidity; ffpos.light = n.light; ffpos.co = n.co; if (ffpos.currentTarget) { ffpos.UpdateFocus(); } ; double xpos = (ffpos.lng - m.lngMinMap) / (m.lngMaxMap - m.lngMinMap) * 40.96 - 20.48; double ypos = (ffpos.lat - m.latMinMap) / (m.latMaxMap - m.latMinMap) * 40.96 - 20.48; FFList[index].transform.localPosition = new Vector3((float)xpos, (float)ypos, ffpos.alt); } else { GameObject nobj = (GameObject)Instantiate(FFPrefab); Color nColor = UnityEngine.Random.ColorHSV((float)0.2027, (float)1.2027, 1, 1, 1, 1, 1, 1); nobj.GetComponent <SpriteRenderer>().color = nColor; nobj.GetComponent <TrailRenderer>().startColor = nColor; nColor.a = 0; nobj.GetComponent <TrailRenderer>().endColor = nColor; var data = nobj.GetComponent <CircleData>(); data.lat = n.lat; data.lng = n.lon; data.alt = n.alt; data.id = n.id; data.tmp = n.temp; data.time = n.time; data.humidity = n.humidity; data.light = n.light; data.co = n.co; data.RestManager = NetworkManager; data.Spawner = Spawner; data.Self = nobj; data.FocusWindow = FocusWindow; data.TargetPrefab = TargetPrefab; nobj.transform.parent = Spawner.transform; nobj.GetComponent <Transform>().localScale = new Vector3(DotScale * ZoomController.ZoomScale, DotScale * ZoomController.ZoomScale, 1); FFList.Add(nobj); Panel.GetComponent <LocationController>().UpdateMap(); terminal.GetComponent <TerminalController>().TerminalColorPrint("New FF object with ID: " + data.id, Color.cyan); } } } if (UIFunctions.closeScene) { foreach (GameObject ff in FFList) { Destroy(ff); } FFList.Clear(); } }