// Update is called once per frame void Update() { if (_updatepos && _oldPos != _player.transform.position) { Vector3 pos = _player.transform.position; string request = string.Format("/data?x={0}&z={1}&radio={2}", pos.x, pos.z, _visibleRadio); _client.AsyncRequest(request, ERestMethod.GET, null, Callback); _oldPos = _player.transform.position; _updatepos = false; } if (_lastcallend) { for (int i = 0; i < root.features.Count; i++) { Feature feature = root.features[i]; if (!_ids.ContainsKey(feature.id)) { GameObject obj = DrawFeature(feature); _ids.Add(feature.id, obj); } else { DestroyObject(_ids[feature.id]); _ids.Remove(feature.id); } } _lastcallend = false; } }
// Use this for initialization void Start() { _client = new HttpRestClient("http://localhost:3000", "application/json"); _player = GameObject.FindWithTag("Player"); _oldPos = _player.transform.position; _ids = new Dictionary <int, GameObject>(); string request = string.Format("/data?x={0}&z={1}&radio={2}", _oldPos.x, _oldPos.z, _visibleRadio); _client.AsyncRequest(request, ERestMethod.GET, null, Callback); }