internal void OnGUI() { GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, "grey_border"); GUILayout.Space(3); GUILayout.Label(Styles.header, EditorStyles.boldLabel); GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.nameLabel, GUILayout.Width(90f)); m_Name = EditorGUILayout.TextField(m_Name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.gridLabel, GUILayout.Width(90f)); m_Layout = (Grid.CellLayout)EditorGUILayout.EnumPopup(m_Layout); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.sizeLabel, GUILayout.Width(90f)); m_CellSizing = (GridPalette.CellSizing)EditorGUILayout.EnumPopup(m_CellSizing); GUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(m_CellSizing == GridPalette.CellSizing.Automatic)) { GUILayout.BeginHorizontal(); GUILayout.Label(GUIContent.none, GUILayout.Width(90f)); m_CellSize = EditorGUILayout.Vector3Field(GUIContent.none, m_CellSize); GUILayout.EndHorizontal(); } GUILayout.Space(5f); // Cancel, Ok GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(Styles.cancel)) { Close(); } using (new EditorGUI.DisabledScope(String.IsNullOrEmpty(m_Name))) { if (GUILayout.Button(Styles.ok)) { GameObject go = GridPaletteUtility.CreateNewPaletteNamed(m_Name, m_Layout, m_CellSizing, m_CellSize); if (go != null) { m_Owner.palette = go; m_Owner.Repaint(); } Close(); GUIUtility.ExitGUI(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); }
public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { switch (layout) { case GridLayout.CellLayout.Hexagon: { var rotationDirection = direction == RotationDirection.Clockwise ? 60 : -60; var rotationAxis = GridManager.Instance.GetRotationAxisVector(); Quaternion orientation = Quaternion.Euler(rotationAxis * rotationDirection); foreach (BrushCell cell in m_Cells) { cell.orientation = cell.orientation * orientation; } } break; case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: case GridLayout.CellLayout.Rectangle: { var rotationDirection = direction == RotationDirection.Clockwise ? 90 : -90; var rotationAxis = GridManager.Instance.GetRotationAxisVector(); Quaternion orientation = Quaternion.Euler(rotationAxis * rotationDirection); foreach (BrushCell cell in m_Cells) { cell.orientation = cell.orientation * orientation; } #if UNITY_EDITOR // Rotate the selected tile in the collection (if any) TilePaletteGridTileBrushEditor.Instance.RotateSelectedTile(orientation); #endif } break; } }
public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { Vector3Int oldSize = m_Size; BrushCell[] oldCells = m_Cells.Clone() as BrushCell[]; size = new Vector3Int(oldSize.y, oldSize.x, oldSize.z); BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, oldSize); foreach (Vector3Int oldPos in oldBounds.allPositionsWithin) { int newX = direction == RotationDirection.Clockwise ? oldSize.y - oldPos.y - 1 : oldPos.y; int newY = direction == RotationDirection.Clockwise ? oldPos.x : oldSize.x - oldPos.x - 1; int toIndex = GetCellIndex(newX, newY, oldPos.z); int fromIndex = GetCellIndex(oldPos.x, oldPos.y, oldPos.z, oldSize.x, oldSize.y, oldSize.z); m_Cells[toIndex] = oldCells[fromIndex]; } int newPivotX = direction == RotationDirection.Clockwise ? oldSize.y - pivot.y - 1 : pivot.y; int newPivotY = direction == RotationDirection.Clockwise ? pivot.x : oldSize.x - pivot.x - 1; pivot = new Vector3Int(newPivotX, newPivotY, pivot.z); Matrix4x4 rotation = direction == RotationDirection.Clockwise ? s_Clockwise : s_CounterClockwise; foreach (BrushCell cell in m_Cells) { Matrix4x4 oldMatrix = cell.matrix; cell.matrix = oldMatrix * rotation; } }
/// <summary> /// Rotates the brush by 90 degrees in the given direction. /// </summary> /// <param name="direction">Direction to rotate by.</param> /// <param name="layout">Cell Layout for rotating.</param> public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { Vector3Int oldSize = m_Size; BrushCell[] oldCells = m_Cells.Clone() as BrushCell[]; size = new Vector3Int(oldSize.y, oldSize.x, oldSize.z); BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, oldSize); foreach (Vector3Int oldPos in oldBounds.allPositionsWithin) { int newX = direction == RotationDirection.Clockwise ? oldSize.y - oldPos.y - 1 : oldPos.y; int newY = direction == RotationDirection.Clockwise ? oldPos.x : oldSize.x - oldPos.x - 1; int toIndex = GetCellIndex(newX, newY, oldPos.z); int fromIndex = GetCellIndex(oldPos.x, oldPos.y, oldPos.z, oldSize.x, oldSize.y, oldSize.z); m_Cells[toIndex] = oldCells[fromIndex]; } int newPivotX = direction == RotationDirection.Clockwise ? oldSize.y - pivot.y - 1 : pivot.y; int newPivotY = direction == RotationDirection.Clockwise ? pivot.x : oldSize.x - pivot.x - 1; pivot = new Vector3Int(newPivotX, newPivotY, pivot.z); Matrix4x4 rotation = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, direction == RotationDirection.Clockwise ? 90f : -90f), Vector3.one); Quaternion orientation = Quaternion.Euler(0f, 0f, direction == RotationDirection.Clockwise ? 90f : -90f); foreach (BrushCell cell in m_Cells) { cell.offset = rotation * cell.offset; cell.orientation = cell.orientation * orientation; } }
public static GameObject CreateNewPalette(string folderPath, string name, Grid.CellLayout layout, GridPalette.CellSizing cellSizing, Vector3 cellSize, Grid.CellSwizzle swizzle) { GameObject temporaryGO = new GameObject(name); Grid grid = temporaryGO.AddComponent <Grid>(); // We set size to kEpsilon to mark this as new uninitialized palette // Nice default size can be decided when first asset is dragged in grid.cellSize = cellSize; grid.cellLayout = layout; grid.cellSwizzle = swizzle; CreateNewLayer(temporaryGO, "Layer1", layout); string path = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + name + ".prefab"); Object prefab = PrefabUtility.CreateEmptyPrefab(path); GridPalette palette = GridPalette.CreateInstance <GridPalette>(); palette.name = "Palette Settings"; palette.cellSizing = cellSizing; AssetDatabase.AddObjectToAsset(palette, prefab); PrefabUtility.ReplacePrefab(temporaryGO, prefab, ReplacePrefabOptions.Default); AssetDatabase.Refresh(); GameObject.DestroyImmediate(temporaryGO); return(AssetDatabase.LoadAssetAtPath <GameObject>(path)); }
public static GameObject CreateNewLayer(GameObject paletteGO, string name, Grid.CellLayout layout) { GameObject newLayerGO = new GameObject(name); var tilemap = newLayerGO.AddComponent <Tilemap>(); var renderer = newLayerGO.AddComponent <TilemapRenderer>(); newLayerGO.transform.parent = paletteGO.transform; newLayerGO.layer = paletteGO.layer; // Set defaults for certain layouts switch (layout) { case Grid.CellLayout.Hexagon: { tilemap.tileAnchor = Vector3.zero; break; } case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: { // Difficult to frame isometric sprites, set generic cell size which suits most cases paletteGO.GetComponent <Grid>().cellSize = new Vector3(1f, 0.5f, 1f); renderer.sortOrder = TilemapRenderer.SortOrder.TopRight; break; } } return(newLayerGO); }
public static GameObject CreateNewLayer(GameObject paletteGO, string name, Grid.CellLayout layout) { var new_layer_go = new GameObject(name); var tilemap = new_layer_go.AddComponent <Tilemap>(); var renderer = new_layer_go.AddComponent <TilemapRenderer>(); new_layer_go.transform.parent = paletteGO.transform; new_layer_go.layer = paletteGO.layer; // Set defaults for certain layouts switch (layout) { case Grid.CellLayout.Hexagon: { tilemap.tileAnchor = Vector3.zero; break; } case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: { renderer.sortOrder = TilemapRenderer.SortOrder.TopRight; break; } } return(new_layer_go); }
public static GameObject CreateNewPalette(string folder_path, string name, Grid.CellLayout layout, GridPalette.CellSizing cell_sizing, Vector3 cell_size, Grid.CellSwizzle swizzle) { var tmp_go = new GameObject(name); var grid = tmp_go.AddComponent <Grid>(); // We set size to kEpsilon to mark this as new uninitialized palette // Nice default size can be decided when first asset is dragged in grid.cellSize = cell_size; grid.cellLayout = layout; grid.cellSwizzle = swizzle; CreateNewLayer(tmp_go, "Layer1", layout); var path = AssetDatabase.GenerateUniqueAssetPath(folder_path + "/" + name + ".prefab"); Object prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(tmp_go, path, InteractionMode.AutomatedAction); var palette = GridPalette.CreateInstance <GridPalette>(); palette.name = "Palette Settings"; palette.cellSizing = cell_sizing; AssetDatabase.AddObjectToAsset(palette, prefab); PrefabUtility.ApplyPrefabInstance(tmp_go, InteractionMode.AutomatedAction); AssetDatabase.Refresh(); GameObject.DestroyImmediate(tmp_go); return(AssetDatabase.LoadAssetAtPath <GameObject>(path)); }
/// <summary>Flips the brush in the given axis.</summary> /// <param name="flip">Axis to flip by.</param> /// <param name="layout">Cell Layout for flipping.</param> public override void Flip(FlipAxis flip, Grid.CellLayout layout) { if (flip == FlipAxis.X) { FlipX(); } else { FlipY(); } }
public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { if (direction == RotationDirection.CounterClockwise) { m_Tick++; } else { m_Tick--; m_Tick = Mathf.Max(1, m_Tick); } }
public static GameObject CreateNewPaletteNamed(string name, Grid.CellLayout layout, GridPalette.CellSizing cellSizing, Vector3 cellSize, Grid.CellSwizzle swizzle) { string defaultPath = ProjectBrowser.s_LastInteractedProjectBrowser ? ProjectBrowser.s_LastInteractedProjectBrowser.GetActiveFolderPath() : "Assets"; string folderPath = EditorUtility.SaveFolderPanel("Create palette into folder ", defaultPath, ""); folderPath = FileUtil.GetProjectRelativePath(folderPath); if (string.IsNullOrEmpty(folderPath)) { return(null); } return(CreateNewPalette(folderPath, name, layout, cellSizing, cellSize, swizzle)); }
private void FlipY(Grid.CellLayout layout) { BrushCell[] oldCells = m_Cells.Clone() as BrushCell[]; BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, m_Size); foreach (Vector3Int oldPos in oldBounds.allPositionsWithin) { int newY = m_Size.y - oldPos.y - 1; int toIndex = GetCellIndex(oldPos.x, newY, oldPos.z); int fromIndex = GetCellIndex(oldPos); m_Cells[toIndex] = oldCells[fromIndex]; } int newPivotY = m_Size.y - pivot.y - 1; pivot = new Vector3Int(pivot.x, newPivotY, pivot.z); FlipCells(ref m_Cells, new Vector3(1f, -1f, 1f), layout == GridLayout.CellLayout.Hexagon); }
public void CreatePalette_ReturnsValidPalettesWithGridAndChildTilemap(Grid.CellLayout layout, GridLayout.CellSwizzle swizzle) { int paletteCount = GridPalettes.palettes.Count; GameObject palette1 = GridPaletteUtility.CreateNewPalette(path, name, layout, GridPalette.CellSizing.Automatic, Vector3.one, swizzle); GameObject palette2 = GridPaletteUtility.CreateNewPalette(path2, name2, layout, GridPalette.CellSizing.Automatic, Vector3.one, swizzle); GridPalettes.CleanCache(); Assert.AreEqual(paletteCount + 2, GridPalettes.palettes.Count); Assert.NotNull(palette1.GetComponent <Grid>()); Assert.NotNull(palette1.GetComponentInChildren <Tilemap>()); Assert.NotNull(palette2.GetComponent <Grid>()); Assert.NotNull(palette2.GetComponentInChildren <Tilemap>()); }
/// <summary>Rotates the brush by 90 degrees in the given direction.</summary> /// <param name="direction">Direction to rotate by.</param> /// <param name="layout">Cell Layout for rotating.</param> public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { switch (layout) { case GridLayout.CellLayout.Hexagon: RotateHexagon(direction); break; case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: case GridLayout.CellLayout.Rectangle: { Vector3Int oldSize = m_Size; BrushCell[] oldCells = m_Cells.Clone() as BrushCell[]; size = new Vector3Int(oldSize.y, oldSize.x, oldSize.z); BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, oldSize); foreach (Vector3Int oldPos in oldBounds.allPositionsWithin) { int newX = direction == RotationDirection.Clockwise ? oldSize.y - oldPos.y - 1 : oldPos.y; int newY = direction == RotationDirection.Clockwise ? oldPos.x : oldSize.x - oldPos.x - 1; int toIndex = GetCellIndex(newX, newY, oldPos.z); int fromIndex = GetCellIndex(oldPos.x, oldPos.y, oldPos.z, oldSize.x, oldSize.y, oldSize.z); m_Cells[toIndex] = oldCells[fromIndex]; } int newPivotX = direction == RotationDirection.Clockwise ? oldSize.y - pivot.y - 1 : pivot.y; int newPivotY = direction == RotationDirection.Clockwise ? pivot.x : oldSize.x - pivot.x - 1; pivot = new Vector3Int(newPivotX, newPivotY, pivot.z); Matrix4x4 rotation = direction == RotationDirection.Clockwise ? s_Clockwise : s_CounterClockwise; Matrix4x4 counterRotation = direction != RotationDirection.Clockwise ? s_Clockwise : s_CounterClockwise; foreach (BrushCell cell in m_Cells) { Matrix4x4 oldMatrix = cell.matrix; bool counter = (oldMatrix.lossyScale.x < 0) ^ (oldMatrix.lossyScale.y < 0); cell.matrix = oldMatrix * (counter ? counterRotation : rotation); } } break; } }
public static GameObject CreateNewLayer(GameObject paletteGO, string name, Grid.CellLayout layout) { GameObject newLayerGO = new GameObject(name); var tilemap = newLayerGO.AddComponent <Tilemap>(); newLayerGO.AddComponent <TilemapRenderer>(); newLayerGO.transform.parent = paletteGO.transform; newLayerGO.layer = paletteGO.layer; // Set defaults for certain layouts switch (layout) { case Grid.CellLayout.Hexagon: { tilemap.tileAnchor = Vector3.zero; break; } } return(newLayerGO); }
public static GameObject CreateNewLayer(GameObject paletteGO, string name, Grid.CellLayout layout) { GameObject newLayerGO = new GameObject(name); newLayerGO.AddComponent <Tilemap>(); newLayerGO.AddComponent <TilemapRenderer>(); newLayerGO.transform.parent = paletteGO.transform; newLayerGO.layer = paletteGO.layer; // Set defaults for certain layouts switch (layout) { case Grid.CellLayout.Rectangle: { paletteGO.GetComponent <Grid>().cellSize = new Vector3(1f, 1f, 0f); break; } } return(newLayerGO); }
public void PalettePrefabIsUpdated_DoesNotCreateAnInstanceInScene(Grid.CellLayout layout, GridLayout.CellSwizzle swizzle) { var palettePrefab = GridPaletteUtility.CreateNewPalette(path, name, layout, GridPalette.CellSizing.Automatic, Vector3.one, swizzle); var w = CreatePaletteWindow(); w.palette = palettePrefab; Object[] objs = GameObject.FindObjectsOfType <Grid>(); Assert.AreEqual(0, objs.Length, "There should be 0 Grids in this test as Palette instances have HideAndDontSave hide flags"); var sceneGameObject = (GameObject)PrefabUtility.InstantiatePrefab(palettePrefab); var grid = sceneGameObject.GetComponent <Grid>(); Object[] objsAfterInstantiatePrefab = GameObject.FindObjectsOfType <Grid>(); Assert.AreEqual(1, objsAfterInstantiatePrefab.Length, "There should be 1 Grid in this test which is the instantiated prefab."); Assert.AreEqual(objsAfterInstantiatePrefab[0], grid, "The Grid found should be the Grid instantiated from the prefab."); grid.cellGap = new Vector3(2.0f, 2.0f, 0.0f); PrefabUtility.SaveAsPrefabAssetAndConnect(sceneGameObject, AssetDatabase.GetAssetPath(palettePrefab), InteractionMode.AutomatedAction); Object[] objsAfterReplacePrefab = GameObject.FindObjectsOfType <Grid>(); Assert.AreEqual(1, objsAfterReplacePrefab.Length, "There should be 1 Grid in this test which is the instantiated prefab after replacing the prefab."); Assert.AreEqual(objsAfterReplacePrefab[0], grid, "The Grid found should be the Grid instantiated from the prefab after replacing the prefab."); // Clean up Object.DestroyImmediate(sceneGameObject); }
internal void OnGUI() { GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, "grey_border"); GUILayout.Space(3); GUILayout.Label(Styles.header, EditorStyles.boldLabel); GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.nameLabel, GUILayout.Width(90f)); m_Name = EditorGUILayout.TextField(m_Name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.gridLabel, GUILayout.Width(90f)); EditorGUI.BeginChangeCheck(); var newLayout = (Grid.CellLayout)EditorGUILayout.EnumPopup(m_Layout); if (EditorGUI.EndChangeCheck()) { // Set useful user settings for certain layouts switch (newLayout) { case Grid.CellLayout.Rectangle: case Grid.CellLayout.Hexagon: { m_CellSizing = GridPalette.CellSizing.Automatic; m_CellSize = new Vector3(1, 1, 0); break; } case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: { m_CellSizing = GridPalette.CellSizing.Manual; m_CellSize = new Vector3(1, 0.5f, 1); break; } } m_Layout = newLayout; } GUILayout.EndHorizontal(); if (m_Layout == GridLayout.CellLayout.Hexagon) { GUILayout.BeginHorizontal(); float oldLabelWidth = UnityEditor.EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 94; m_HexagonLayout = EditorGUILayout.Popup(Styles.hexagonLabel, m_HexagonLayout, Styles.hexagonSwizzleTypeLabel); EditorGUIUtility.labelWidth = oldLabelWidth; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label(Styles.sizeLabel, GUILayout.Width(90f)); m_CellSizing = (GridPalette.CellSizing)EditorGUILayout.EnumPopup(m_CellSizing); GUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(m_CellSizing == GridPalette.CellSizing.Automatic)) { GUILayout.BeginHorizontal(); GUILayout.Label(GUIContent.none, GUILayout.Width(90f)); m_CellSize = EditorGUILayout.Vector3Field(GUIContent.none, m_CellSize); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); // Cancel, Ok GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(Styles.cancel)) { Close(); } using (new EditorGUI.DisabledScope(!Utils.Paths.IsValidAssetPath(m_Name))) { if (GUILayout.Button(Styles.ok)) { // case 1077362: Close window to prevent overlap with OS folder window when saving new palette asset Close(); var swizzle = Grid.CellSwizzle.XYZ; if (m_Layout == GridLayout.CellLayout.Hexagon) { swizzle = Styles.hexagonSwizzleTypeValue[m_HexagonLayout]; } GameObject go = GridPaletteUtility.CreateNewPaletteNamed(m_Name, m_Layout, m_CellSizing, m_CellSize, swizzle); if (go != null) { m_Owner.palette = go; m_Owner.Repaint(); } GUIUtility.ExitGUI(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); }
public override void Flip(FlipAxis flip, Grid.CellLayout layout) { Debug.Log("Flip not supported"); }
public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { Debug.Log("Rotate not supported for GridObjects, set their initial orientation on the editor instead"); }
public void PaintDifferentSizedTilesOnAutomaticCellSizePalette_UpdatesPaletteCellSize(Grid.CellLayout layout, GridLayout.CellSwizzle swizzle, int tileX, int tileY, float expectedCellXSize, float expectedCellYSize) { var smallTile = AssetDatabase.LoadAssetAtPath <Tile>(tilePath); var bigTile = AssetDatabase.LoadAssetAtPath <Tile>(bigTilePath); var newPalette = GridPaletteUtility.CreateNewPalette(path, name, layout, GridPalette.CellSizing.Automatic, Vector3.one, swizzle); var tilemap = newPalette.GetComponentInChildren <Tilemap>(); tilemap.SetTile(new Vector3Int(tileX, tileY, 0), bigTile); var w = CreatePaletteWindow(); w.palette = newPalette; w.clipboardView.previewUtility.camera.orthographicSize = 1000; w.clipboardView.ClampZoomAndPan(); Assert.GreaterOrEqual(GridPaletteBrushes.brushes.Count, 1); GridPaintingState.defaultBrush.Init(new Vector3Int(1, 1, 1)); GridPaintingState.defaultBrush.SetTile(Vector3Int.zero, smallTile); w.clipboardView.unlocked = true; TilemapEditorTool.SetActiveEditorTool(typeof(PaintTool)); Event ev = new Event(); ev.mousePosition = w.clipboardView.GridToScreen(new Vector2(tileX + 1.5f, tileY + 1.5f)) + new Vector2(0, paletteHeaderHeight); ev.type = EventType.MouseMove; w.SendEvent(ev); ev.type = EventType.MouseDown; w.SendEvent(ev); ev.type = EventType.MouseUp; w.SendEvent(ev); w.clipboardView.unlocked = false; var grid = w.palette.GetComponent <Grid>(); Assert.AreEqual(expectedCellXSize, grid.cellSize.x); Assert.AreEqual(expectedCellYSize, grid.cellSize.y); }
internal void OnGUI() { GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, "grey_border"); GUILayout.Space(3); GUILayout.Label(Styles.header, EditorStyles.boldLabel); GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.nameLabel, GUILayout.Width(90f)); m_Name = EditorGUILayout.TextField(m_Name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.gridLabel, GUILayout.Width(90f)); m_Layout = (Grid.CellLayout)EditorGUILayout.EnumPopup(m_Layout); GUILayout.EndHorizontal(); if (m_Layout == GridLayout.CellLayout.Hexagon) { GUILayout.BeginHorizontal(); float oldLabelWidth = UnityEditor.EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 94; m_HexagonLayout = EditorGUILayout.Popup(Styles.hexagonLabel, m_HexagonLayout, Styles.hexagonSwizzleTypeLabel); EditorGUIUtility.labelWidth = oldLabelWidth; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label(Styles.sizeLabel, GUILayout.Width(90f)); m_CellSizing = (GridPalette.CellSizing)EditorGUILayout.EnumPopup(m_CellSizing); GUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(m_CellSizing == GridPalette.CellSizing.Automatic)) { GUILayout.BeginHorizontal(); GUILayout.Label(GUIContent.none, GUILayout.Width(90f)); m_CellSize = EditorGUILayout.Vector3Field(GUIContent.none, m_CellSize); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); // Cancel, Ok GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(Styles.cancel)) { Close(); } using (new EditorGUI.DisabledScope(!Utils.Paths.IsValidAssetPath(m_Name))) { if (GUILayout.Button(Styles.ok)) { var swizzle = Grid.CellSwizzle.XYZ; if (m_Layout == GridLayout.CellLayout.Hexagon) { swizzle = Styles.hexagonSwizzleTypeValue[m_HexagonLayout]; } GameObject go = GridPaletteUtility.CreateNewPaletteNamed(m_Name, m_Layout, m_CellSizing, m_CellSize, swizzle); if (go != null) { m_Owner.palette = go; m_Owner.Repaint(); } GUIUtility.ExitGUI(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); }