public static void UnloadTerrain(TerrainReference terrain) { if (instance.allTerrains.Contains(terrain)) { instance.allTerrains.Remove(terrain); instance.terrainGrid.Remove(new Point(terrain.xTile, terrain.yTile)); } }
public static TerrainReference GetNeighbour(int xAdd, int yAdd, TerrainReference cur) { if (instance.terrainGrid.ContainsKey(new Point(cur.xTile + xAdd, cur.yTile + yAdd))) { return(instance.terrainGrid[new Point(cur.xTile + xAdd, cur.yTile + yAdd)]); } return(null); }
private static Box GetFirstTerrainTileExtent([NotNull] TerrainReference terrain) { double xMin = terrain.Tiling.OriginX; double yMin = terrain.Tiling.OriginY; double tileSize = terrain.Tiling.TileWidth; return(new Box(new Pnt2D(xMin, yMin), new Pnt2D(xMin + tileSize, yMin + tileSize))); }
public TerrainRowEnumerable([NotNull] TerrainReference terrainRef, double resolution, [NotNull] ITestProgress progress) { _terrainReference = terrainRef; _resolution = resolution; FirstTerrainBox = GetFirstTerrainTileExtent(terrainRef); _progress = progress; }
private void Update() { if (streaming && ld) { if (terrainPoint.loadedTerrain.highLOD.gameObject.activeInHierarchy == false) { terrainPoint.loadedTerrain.highLOD.gameObject.SetActive(true); terrainPoint.loadedTerrain.highRenderer.enabled = true; terrainPoint.loadedTerrain.midLOD.gameObject.SetActive(false); } if (!PlayerIsInBounds(terrainPoint)) { //New terrain must be checked. Has to be in a neighbour, don't use raycasts too uncertain for (int i = 0; i < visibleNeighbours.Count; i++) { if (PlayerIsInBounds(visibleNeighbours[i]) && terrainPoint != visibleNeighbours[i]) { terrainPoint = visibleNeighbours[i]; terrainPoint.loadedTerrain.highLOD.gameObject.SetActive(true); terrainPoint.loadedTerrain.highRenderer.enabled = true; terrainPoint.loadedTerrain.midLOD.gameObject.SetActive(false); visibleNeighbours[i].loadedTerrain.lowLOD.gameObject.SetActive(false); break; } } if (!visibleNeighbours.Contains(terrainPoint)) { visibleNeighbours.Add(terrainPoint); } UnloadAndLoadVisible(); LoadVisibleNeighbours(); EvaluateDistanceRules(); } else { t -= Time.deltaTime; if (t <= 1) { manager.RegularClearup(); } if (t <= 0) { UnloadAndLoadVisible(); t = tRandomCheck; } } } }
public bool PlayerIsInBounds(TerrainReference currentTerrain) { if (currentTerrain.loaded == false || currentTerrain.loadedTerrain == null) { return(false); } if (player.position.x > currentTerrain.loadedTerrain.max.x && player.position.x < currentTerrain.loadedTerrain.min.x && player.position.z > currentTerrain.loadedTerrain.max.z && player.position.z < currentTerrain.loadedTerrain.min.z) { return(true); } return(false); }
public void LoadVisibleNeighbours() { if (terrainPoint.loaded == false) { loadQueue.Enqueue(terrainPoint); } for (int x = -radiusX; x < radiusX + 1; x++) { for (int y = -radiusY; y < radiusY + 1; y++) { int neighX = -terrainPoint.xTile + x; int neighY = terrainPoint.yTile + y; if (x == 0 && y == 0) { continue; } //Double inv. if (manager.terrainGrid.ContainsKey(new Point(-neighX, neighY))) { TerrainReference refT = manager.terrainGrid[new Point(-neighX, neighY)]; if (refT.loaded) { if (!visibleNeighbours.Contains(refT)) { visibleNeighbours.Add(refT); } } else { //Load into scene loadQueue.Enqueue(refT); if (!visibleNeighbours.Contains(refT)) { visibleNeighbours.Add(refT); } } } } } if (loadQueue.Count > 0) { StartCoroutine("LoadChunks"); } }
//This is used when the SceneManagement tool adds a new scene in - so it has to be registered. public static void LoadTerrain(TerrainReference terrain) { if (!instance.allTerrains.Contains(terrain)) { if (instance.terrainGrid.ContainsKey(new Point(terrain.xTile, terrain.yTile))) { instance.terrainGrid[new Point(terrain.xTile, terrain.yTile)] = terrain; } else { instance.terrainGrid.Add(new Point(terrain.xTile, terrain.yTile), terrain); } instance.allTerrains.Add(terrain); return; } }
public void NonStaticLoadTerrain(TerrainReference terrain) { if (!allTerrains.Contains(terrain)) { if (terrainGrid.ContainsKey(new Point(terrain.xTile, terrain.yTile))) { terrainGrid[new Point(terrain.xTile, terrain.yTile)] = terrain; } else { terrainGrid.Add(new Point(terrain.xTile, terrain.yTile), terrain); } allTerrains.Add(terrain); return; } Debug.LogWarning("Trying to add a terrain that exists?"); }
public void EdgeCombine() { for (int x = -1 - 1; x < 1 + 2; x++) { for (int y = -1 - 1; y < 1 + 2; y++) { if (x == 0 && y == 0) { continue; } int neighX = xTile + x; int neighY = yTile + y; if (GameObject.FindObjectOfType <TerrainManager>().terrainGrid.ContainsKey(new Point(neighX, neighY))) { TerrainReference neighboru = TerrainManager.instance.terrainGrid[new Point(neighX, neighY)]; bool gLX = (neighX > xTile) || (neighX < xTile); bool gLY = (neighY > yTile) || (neighY < yTile); if (gLX && gLY) { continue; } if (!neighboru.loaded || neighboru.loadedTerrain == null) { continue; } if (neighX > xTile) { Stitch(edges, neighboru.GetSideEdges("right", neighboru.loadedTerrain.midLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.midLOD); Stitch(edges, neighboru.GetSideEdges("right", neighboru.loadedTerrain.highLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.highLOD); continue; } if (neighX < xTile) { Stitch(edges, neighboru.GetSideEdges("left", neighboru.loadedTerrain.midLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.midLOD); Stitch(edges, neighboru.GetSideEdges("left", neighboru.loadedTerrain.highLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.highLOD); continue; } if (neighY > yTile) { Stitch(edges, neighboru.GetSideEdges("up", neighboru.loadedTerrain.midLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.midLOD); Stitch(edges, neighboru.GetSideEdges("up", neighboru.loadedTerrain.highLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.highLOD); continue; } if (neighY < yTile) { Stitch(edges, neighboru.GetSideEdges("down", neighboru.loadedTerrain.midLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.midLOD); Stitch(edges, neighboru.GetSideEdges("down", neighboru.loadedTerrain.highLOD), loadedTerrain.highLOD, neighboru.loadedTerrain.highLOD); continue; } } } } /* */ }
private void Update() { if (!Application.isPlaying || !editingSingleTerrain) { return; } Vector3 mP = Input.mousePosition; Ray ray = Camera.main.ScreenPointToRay(mP); RaycastHit hit; Vector3 centerPoint = Vector3.zero; //This code manages finding the points that you have hovered over when the game is playing if (Physics.Raycast(ray, out hit)) { editorTemporaryNoiseGenerator = hit.transform.root.root.GetComponent <NoiseGenerator>(); Vector3[] vertices = hit.transform.GetComponent <MeshFilter>().sharedMesh.vertices; int[] triangles = hit.transform.GetComponent <MeshFilter>().sharedMesh.triangles; Vector3 p0 = vertices[triangles[hit.triangleIndex * 3 + 0]]; Vector3 p1 = vertices[triangles[hit.triangleIndex * 3 + 1]]; Vector3 p2 = vertices[triangles[hit.triangleIndex * 3 + 2]]; Transform hitTransform = hit.collider.transform; p0 = hitTransform.TransformPoint(p0); p1 = hitTransform.TransformPoint(p1); p2 = hitTransform.TransformPoint(p2); Debug.DrawLine(p0, p1, Color.red, 0.2f); Debug.DrawLine(p1, p2, Color.red, 0.2f); Debug.DrawLine(p2, p0, Color.red, 0.2f); //Find the average point on the mesh where your mouse is centerPoint = (p0 + p1 + p2) / 3; Debug.DrawLine(centerPoint, centerPoint + Vector3.up * 2, Color.green, 0.2f); } else { editorTemporaryNoiseGenerator = null; } if (editorTemporaryNoiseGenerator == null) { return; } Texture2D brush = new Texture2D(0, 0); editorTemporaryNoiseGenerator.brushScale = Mathf.Clamp(editorTemporaryNoiseGenerator.brushScale + Mathf.RoundToInt(Input.GetAxis("Mouse ScrollWheel")), 1, 6); float intensity2 = 0f; if (editorTemporaryNoiseGenerator != null && editorTemporaryNoiseGenerator.brush != null) { //Intensity of the brsuh intensity2 = editorTemporaryNoiseGenerator.intensity; if (scale != editorTemporaryNoiseGenerator.brushScale) { //Supporting the scaling of the brush (settings can be changed in NoiseGenerator.cs) TextureScale.Bilinear(editorTemporaryNoiseGenerator.brush, Mathf.RoundToInt(editorTemporaryNoiseGenerator.initialResolution.x * editorTemporaryNoiseGenerator.brushScale), Mathf.RoundToInt(editorTemporaryNoiseGenerator.initialResolution.y * editorTemporaryNoiseGenerator.brushScale)); } //Setting the current brush to the noise generator's brush (can change per terrain) brush = editorTemporaryNoiseGenerator.brush; scale = editorTemporaryNoiseGenerator.brushScale; } if (editorTemporaryNoiseGenerator != null) { (tempXA, tempYA) = editorTemporaryNoiseGenerator.FindUVTextureIndex(centerPoint); } if (Input.GetMouseButton(0)) { if (editingVerts) { NoiseGenerator g = editorTemporaryNoiseGenerator; if (g == null) { return; } (int a, int b, float[] vals) = g.FindTextureIndex(centerPoint); int size = g.size; int xtemp = 0; List <NoiseGenerator> tempTerrains = new List <NoiseGenerator>(4); for (int x = a - (brush.width) / 2; x < a + (brush.width) / 2; x++) { int ytemp = 0; float overallInt = 1f; for (int y = b - (brush.height) / 2; y < b + (brush.height) / 2; y++) { float brushAlpha = brush.GetPixel(xtemp, ytemp).a; u = false; bool smoothing = false; int mult = 1; if (Input.GetKey(KeyCode.LeftShift)) { mult = -1; } if (Input.GetKey(KeyCode.LeftControl)) { smoothing = true; } float ar = 0; if (x > g.size - 1 || y > g.size - 1 || x < 0 || y < 0) { //x = y //- = + if (x > g.size - 1) { if (y > g.size - 1) { NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(g.xTile - 1, g.yTile - 1); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessX = x - (g2.size); int excessY = y - (g2.size); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { vr = Mathf.Clamp01(g2.vals[(excessX) * size + excessY] + (0.03f * intensity)); g2.vals[(excessX) * size + excessY] = vr; // g2.matTex.SetPixel((excessX), excessY, new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } } catch (System.Exception) { } } } else if (y < 0) { NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(g.xTile + 1, g.yTile - 1); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessX = x - (g2.size); int excessY = Mathf.Abs(y); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { vr = Mathf.Clamp01(g2.vals[(excessX) * size + (g2.size - excessY)] + (0.03f * intensity)); g2.vals[(excessX) * size + (g2.size - excessY)] = vr; // g2.matTex.SetPixel((excessX), (g2.size - excessY), new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } } catch (System.Exception) { } } } } if (x < 0) { if (y > g.size - 1) { NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(g.xTile - 1, g.yTile + 1); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessX = Mathf.Abs(x); int excessY = y - (g2.size); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { vr = Mathf.Clamp01(g2.vals[(g.size - excessX) * size + excessY] + (0.03f * intensity)); g2.vals[(g.size - excessX) * size + excessY] = vr; // g2.matTex.SetPixel((g.size - excessX), excessY, new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } } catch (System.Exception) { } } } else if (y < 0) { NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(g.xTile + 1, g.yTile + 1); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessX = Mathf.Abs(x); int excessY = Mathf.Abs(y); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { vr = Mathf.Clamp01(g2.vals[(g.size - excessX) * size + (g2.size - excessY)] + (0.03f * intensity)); g2.vals[(g.size - excessX) * size + (g2.size - excessY)] = vr; // g2.matTex.SetPixel((g.size - excessX), (g2.size - excessY), new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } } catch (System.Exception) { } } } } if (x > g.size - 1) { int place = g.yTile - 1; NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(g.xTile, place); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessX = x - (g2.size); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { if (y >= 0 && y < size) { vr = Mathf.Clamp01(g2.vals[(excessX) * size + y] + (0.03f * intensity)); g2.vals[(excessX) * size + y] = vr; //g2.matTex.SetPixel((excessX), y, new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } } } catch (System.Exception) { } } } //This wont work for all y vals if (x < 0) { int place = g.yTile + 1; NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(g.xTile, place); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessX = Mathf.Abs(x); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { if (y >= 0 && y < size) { vr = Mathf.Clamp01(g2.vals[(g.size - excessX) * size + y] + (0.03f * intensity)); g2.vals[(g.size - excessX) * size + y] = vr; //g2.matTex.SetPixel((g.size - excessX), y, new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } } } catch (System.Exception) { } } } if (y > g.size - 1) { int place = g.xTile - 1; NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(place, g.yTile); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessY = y - (g2.size); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { // if (y >= 0 && y < size) //{ vr = Mathf.Clamp01(g2.vals[(x) * size + excessY] + (0.03f * intensity)); g2.vals[(x) * size + excessY] = vr; //g2.matTex.SetPixel((x), excessY, new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } // } } catch (System.Exception) { } } } //This wont work for all y vals if (y < 0) { int place = g.xTile + 1; NoiseGenerator g2 = null; TerrainReference rg2 = TerrainManager.GetNeighbour(place, g.yTile); if (rg2 != null) { g2 = rg2.terrain; } if (g2 != null) { int excessY = Mathf.Abs(y); //Here and then it's opposite for them? //Convert the intensity to the local coordinates of the texture (rgba). float vr = 0f; float intensity = brushAlpha * intensity2 * mult; try { // if (y >= 0 && y < size) //{(g.size - excessX) vr = Mathf.Clamp01(g2.vals[(x) * size + (g2.size - excessY)] + (0.03f * intensity)); g2.vals[(x) * size + (g2.size - excessY)] = vr; //g2.matTex.SetPixel((x), (g2.size - excessY), new Color(ar, ar, ar)); if (!tempTerrains.Contains(g2)) { tempTerrains.Add(g2); } // } } catch (System.Exception) { } } } } if (!smoothing) { //Convert the intensity to the local coordinates of the texture (rgba). float intensity = brushAlpha * intensity2 * mult; try { if (y >= 0 && y < size && x >= 0 && x < size) { ar = Mathf.Clamp01(vals[Mathf.Clamp(x, 0, size - 1) * size + y] + (0.03f * intensity)); } } catch (System.Exception) { } } else { /* float intensity = brushAlpha * intensity2 * mult; * ar = Mathf.Clamp01(Mathf.Lerp(vals[Mathf.Clamp(x, 0, size - 1) * size + Mathf.Clamp(y, 0, size - 1)], 0, 0.2f * intensity)) * overallInt;*/ } //g.matTex.SetPixel(Mathf.Clamp(x,0, size - 1), Mathf.Clamp(y, 0, size - 1), new Color(ar, ar, ar)); try { if (y >= 0 && y < size && x >= 0 && x < size) { vals[Mathf.Clamp(x, 0, size - 1) * size + y] = ar; //g.matTex.SetPixel(Mathf.Clamp(x, 0, size - 1), y, new Color(ar, ar, ar)); } } catch (System.Exception e) { } ytemp++; } xtemp++; } g.vals = vals; g.RegsiterChange(); foreach (NoiseGenerator g2 in tempTerrains) { g2.RegsiterChange(); } } else { NoiseGenerator g = editorTemporaryNoiseGenerator; if (g == null) { return; } (int a, int b) = g.FindUVTextureIndex(centerPoint); int size = g.size; int xtemp = 0; for (int x = a - (brush.width) / 2; x < a + (brush.width) / 2; x++) { int ytemp = 0; for (int y = b - (brush.height) / 2; y < b + (brush.height) / 2; y++) { float brushAlpha = brush.GetPixel(xtemp, ytemp).a; bool smoothing = false; int mult = 1; if (Input.GetKey(KeyCode.LeftShift)) { mult = -1; } if (Input.GetKey(KeyCode.LeftControl)) { smoothing = true; } Color ar = new Color(1, 1, 1); if (!smoothing) { Color originalColor = g.uvTex.GetPixel(g.size - 1 - y, x); //Convert the intensity to the local coordinates of the texture (rgba). float intensity = intensity2 * mult; ar = Color.Lerp(originalColor, paintColor, brushAlpha * intensity2); } else { Color originalColor = g.uvTex.GetPixel(g.size - y, x); //Convert the intensity to the local coordinates of the texture (rgba). float intensity = intensity2 * mult; ar = Color.Lerp(originalColor, paintColor, brushAlpha * intensity2 * paintColor.a); } g.uvTex.SetPixel(Mathf.Clamp(g.size - 1 - y, -1, g.size + 1), Mathf.Clamp(x, -1, g.size + 1), ar); //vals[x * size + y] = ar; ytemp++; } xtemp++; } g.uvTex.Apply(); //g.vals = vals; //g.matTex.Apply(); //Registering the change in the texture -> updates the mesh g.RegisterTextureChange(); } } }
private void OnGUI() { GUILayout.BeginHorizontal(); if (GameObject.FindObjectOfType <TerrainManager>() != null) { manager = GameObject.FindObjectOfType <TerrainManager>(); } manager = (TerrainManager)EditorGUILayout.ObjectField(manager, typeof(TerrainManager)); if (Selection.activeTransform != null && Selection.activeTransform.GetComponent <SceneHandler>() != null) { NoiseGenerator g = Selection.activeGameObject.transform.GetComponent <NoiseGenerator>(); selectedNoise = g; if (g == null) { Debug.LogError("You can't have a SceneHandler without a NoiseGenerator"); } if (GameObject.Find("TerrainHolder (" + g.xTile + "," + g.yTile + ")") != null) { selectedTerrain = GameObject.Find("TerrainHolder (" + g.xTile + "," + g.yTile + ")").GetComponent <TerrainReference>(); } selectedHandler = Selection.activeGameObject.transform.GetComponent <SceneHandler>(); if (selectedTerrain != null) { GUILayout.Label("Selected : " + selectedTerrain.terrainID + " at " + " X : " + selectedTerrain.xTile + " Y : " + selectedTerrain.yTile); } else { GUILayout.Label("Selected : " + g.terrainID + " at " + " X : " + g.xTile + " Y : " + g.yTile); } } else if (Selection.activeTransform != null && Selection.activeGameObject.transform.GetComponent <TerrainReference>() != null) { selectedTerrain = Selection.activeGameObject.transform.GetComponent <TerrainReference>(); if (selectedTerrain.loaded) { selectedHandler = selectedTerrain.loadedTerrain.GetComponent <SceneHandler>(); GUILayout.Label("Selected : " + selectedTerrain.terrainID + " at " + " X : " + selectedTerrain.xTile + " Y : " + selectedTerrain.yTile); } else { GUILayout.Label("You haven't loaded in the scene yet, so you can't really use this yet."); } } /*else * { * selectedTerrain = (TerrainReference) EditorGUILayout.ObjectField(selectedTerrain, typeof(TerrainReference)); * if (selectedTerrain.loaded) * { * selectedHandler = selectedTerrain.loadedTerrain.GetComponent<SceneHandler>(); * * GUILayout.Label("Selected : " + selectedTerrain.terrainID + " at " + " X : " + selectedTerrain.xTile + " Y : " + selectedTerrain.yTile); * } * else * { * GUILayout.Label("You haven't loaded in the scene yet, so you can't really use this yet."); * } * } */ GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (selectedTerrain != null) { GUILayout.Label("Selected : " + selectedTerrain.terrainID + " at " + " X : " + selectedTerrain.xTile + " Y : " + selectedTerrain.yTile); } else { GUILayout.Label("Selected : " + selectedNoise.terrainID + " at " + " X : " + selectedNoise.xTile + " Y : " + selectedNoise.yTile); } if (GUILayout.Button("Load/Unload")) { selectedHandler.ToggleLoad(editingTag, true); } if (GUILayout.Button("Add Selected to Tag")) { selectedHandler.LoadInObjects(new List <GameObject>(Selection.gameObjects), editingTag, true); } GUILayout.EndHorizontal(); //Selecting objects in scene //Applying tag (create if one doesn't exist) + add to those objects //Aplying tag-type //APplying priority //Add to sub-stream manager [two lists for serialization] GUILayout.BeginHorizontal(); GUILayout.Label("Scene Tag : "); editingTag = GUILayout.TextField(editingTag); EditorGUILayout.Separator(); GUILayout.EndHorizontal(); //Save tag (Load the scene, add, save) EditorGUILayout.BeginVertical(); GUILayout.Label("Create new Sub-Scene : "); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Tag : "); _sceneTagName = GUILayout.TextField(_sceneTagName); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Scene Type : "); _type = (SceneType)EditorGUILayout.EnumPopup(_type); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Create")) { if (selectedTerrain != null) { selectedHandler.CreateScene(new SubsceneTag(_sceneTagName, sceneBuildID, _type, selectedTerrain.terrainID), selectedTerrain.terrainID); } else { selectedHandler.CreateScene(new SubsceneTag(_sceneTagName, sceneBuildID, _type, selectedNoise.terrainID), selectedNoise.terrainID); } } EditorGUILayout.EndVertical(); //---------------- //Loop through tags allow to load / unload + change the settings (type etc.) Repaint(); }