public static Far Create (VoxelTerrain land) { GameObject obj = new GameObject("Far"); obj.transform.parent = land.transform; obj.transform.localPosition = Vector3.zero; Far far = obj.AddComponent<Far>(); far.land = land; obj.AddComponent<MeshRenderer>(); far.filter = obj.AddComponent<MeshFilter>(); //far.filter.sharedMesh = new Mesh(); far.GetComponent<Renderer>().sharedMaterial = land.terrainMaterial; // if (land.hideChunks) far.transform.hideFlags = HideFlags.HideInHierarchy; //hiding wireframe #if UNITY_EDITOR UnityEditor.EditorUtility.SetSelectedWireframeHidden(obj.GetComponent<Renderer>(), land.hideWire); //copy static flag UnityEditor.StaticEditorFlags flags = UnityEditor.GameObjectUtility.GetStaticEditorFlags(land.gameObject); UnityEditor.GameObjectUtility.SetStaticEditorFlags(obj, flags); #endif return far; }
public static void DrawArea (VoxelTerrain land, GeovoxData.Area area) //drawing area in OnSceneGui { #if UNITY_EDITOR float density = 64; for (int x=0; x<density+1; x++) for (int z=0; z<density+1; z++) { float xCoord = area.offsetX + x*area.size/density; float zCoord = area.offsetZ + z*area.size/density; Vector3 start = new Vector3(xCoord, land.data.GetTopPoint((int)xCoord, (int)zCoord), zCoord); Vector3 xPoint = new Vector3(xCoord+area.size/density, land.data.GetTopPoint((int)(xCoord+area.size/density), (int)zCoord), zCoord); Vector3 zPoint = new Vector3(xCoord, land.data.GetTopPoint((int)xCoord, (int)(zCoord+area.size/density)), zCoord+area.size/density); start = land.transform.TransformPoint(start); xPoint = land.transform.TransformPoint(xPoint); zPoint = land.transform.TransformPoint(zPoint); if (x!=density) UnityEditor.Handles.DrawLine(start, xPoint); if (z!=density) UnityEditor.Handles.DrawLine(start, zPoint); } #endif }