void OnSceneGUI() { v = target as VoxelTerrain; if (!v.initialized) { return; } VTPart part = v.getPart(v.edx, v.edy, v.edz); Event e = Event.current; if (e.type == EventType.keyDown) { if (e.control) { if (e.keyCode == KeyCode.RightArrow) { v.edx++; } if (e.keyCode == KeyCode.LeftArrow) { v.edx--; } if (e.keyCode == KeyCode.UpArrow) { v.edz++; } if (e.keyCode == KeyCode.DownArrow) { v.edz--; } if (e.keyCode == KeyCode.Keypad8) { v.edy++; } if (e.keyCode == KeyCode.Keypad2) { v.edy--; } v.edx = Mathf.Clamp(v.edx, 0, v.npart - 1); v.edy = Mathf.Clamp(v.edy, 0, v.npart - 1); v.edz = Mathf.Clamp(v.edz, 0, v.npart - 1); Vector3 cp = Camera.current.transform.position; v.LoadMeshes(cp); } } Vector3 p = new Vector3(v.edx + 0.5f, v.edy + 0.5f, v.edz + 0.5f) * v.partSize; partCube.transform.position = p; partCube.transform.localScale = v.partSize * Vector3.one; /* * int l=v.getPart (v.edx,v.edy,v.edz).getLOD (Camera.current.transform.position); * Handles.BeginGUI (); * GUI.Label(new Rect(10,10,100,100),"LOD: "+l); * Handles.EndGUI (); */ }
void Start() { player = GameObject.FindGameObjectWithTag("Player").transform; v = GameObject.FindObjectOfType(typeof(VoxelTerrain)) as VoxelTerrain; Vector3 cp = Camera.main.transform.position; v.LoadMeshes(cp); }