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(); }
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(); }
public override void Repaint() { m_Owner.Repaint(); }
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(); }