void BuildChunk(WorldChunk chunk) { chunk.ChunkContainer = new GameObject(); chunk.ChunkContainer.transform.localScale = new Vector3(Settings.CunkScale, Settings.CunkScale, Settings.CunkScale); if (chunk.HasLocation) { PlaceAtLocation.AddPlaceAtComponent(chunk.ChunkContainer, chunk.ChunkLocation, new PlaceAtLocation.PlaceAtOptions { MaxNumberOfLocationUpdates = 2 }); chunk.ChunkContainer.transform.localEulerAngles = new Vector3(0, chunk.ChunkRotation, 0); } else { chunk.ChunkContainer.transform.position = chunk.Origin; chunk.Bounds = new Bounds(chunk.Origin, new Vector3(chunk.Length, chunk.Length, chunk.Length)); chunk.ChunkContainer.AddComponent <GroundHeight>(); } foreach (var v in chunk.Voxels) { v.Instance = Instantiate(PrefabDatabase.GetEntryById(v.PrefabId), chunk.ChunkContainer.transform); v.Instance.transform.localPosition = new Vector3(v.i, v.j, v.k); } //if (Elements.ChunkPlanePrefab != null) //{ // chunk.ChunkPlaneInstance = Instantiate(Elements.ChunkPlanePrefab, chunk.ChunkContainer.transform); // chunk.ChunkPlaneInstance.transform.localPosition = new Vector3(0, -0.5f, 0); // //chunk.ChunkPlaneInstance.transform.localScale = new Vector3(5, 1, 5); // chunk.ChunkPlaneInstance.transform.localScale = new Vector3(chunk.Length/10, 1, chunk.Length/10); // //chunk.ChunkPlaneInstance.GetComponent<MeshRenderer>().material.mainTextureScale = new Vector2(50, 50); // chunk.ChunkPlaneInstance.GetComponent<MeshRenderer>().material.mainTextureScale = new Vector2(chunk.Length, chunk.Length); // chunk.ChunkPlaneInstance.GetComponent<MeshRenderer>().material.mainTextureOffset = new Vector2(0.5f, 0.5f); //} }
public void LoadLocationObjects(string message) { var opts = new PlaceAtLocation.PlaceAtOptions() { HideObjectUntilItIsPlaced = true, MaxNumberOfLocationUpdates = 0, MovementSmoothing = 0.05f, UseMovingAverage = false }; Debug.Log(message); var objects = JArray.Parse(message); foreach (JObject location in objects) { Debug.Log(location); double lat = double.Parse((string)location["location"]["latitude"]); double lng = double.Parse((string)location["location"]["longitude"]); JToken sensorData = location["data"]; var entry = new Location() { Latitude = lat, Longitude = lng, Altitude = 0, AltitudeMode = AltitudeMode.GroundRelative }; //Create Game object GameObject newGameObject = Instantiate(Resources.Load("POIPrefab")) as GameObject; newGameObject.transform.SetParent(this.transform); //Create 3D text TextMeshPro textMesh = newGameObject.GetComponentsInChildren <TextMeshPro>(true)[0]; foreach (JObject data in sensorData) { textMesh.text = textMesh.text + (string)data["name"] + ": " + "<color=yellow>" + (string)data["value"] + "</color>" + System.Environment.NewLine; } //Put new Game Object to the Scene PlaceAtLocation.AddPlaceAtComponent(newGameObject, entry, opts); gameObjects.Add(entry, newGameObject); Debug.Log($"{lat}, {lng}, {name}"); } }