private void DrawSettings(int section) { #region Header GUILayout.BeginHorizontal(); { if (!SimpleTiler.hideSection[section]) { if (EditorTools.TexturedButton(EditorTools.eyeOpenTexture, "Hides all the content in this section.", 20f)) { SimpleTiler.hideSection[section] = true; } } else { if (EditorTools.TexturedButton(EditorTools.eyeClosedTexture, "Shows all the content in this section.", 20f)) { SimpleTiler.hideSection[section] = false; } } var style = new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter, fontSize = 13 }; GUILayout.Space(-20); EditorGUILayout.LabelField(new GUIContent("Tile Settings", ""), style); GUILayout.Space(-25); if (EditorTools.TexturedButton(EditorTools.settingsTexture, "Generates the object.", 20f)) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Type"); tiler.Generate(); } } } GUILayout.EndHorizontal(); EditorTools.DrawLine(); GUILayout.Space(5); if (SimpleTiler.hideSection[section]) { return; } #endregion // Draw Debugging Box EditorGUILayout.BeginVertical(_boxStyle, GUILayout.MinWidth(BoxMinWidth), GUILayout.MaxWidth(BoxMaxWidth)); { // Type { EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = LabelWidth; SimpleTiler.tileType = (SimpleTiler.Type)EditorGUILayout.EnumPopup( new GUIContent("Type:", "The type of object to instantiate."), SimpleTiler.tileType); if (EditorGUI.EndChangeCheck()) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Type"); tiler.tileType = SimpleTiler.tileType; } } } // Placement { EditorGUI.BeginChangeCheck(); SimpleTiler.placement = (SimpleTiler.Placement)EditorGUILayout.EnumPopup( new GUIContent("Anchor:", "The position of the anchor point once tiling is finished."), SimpleTiler.placement); if (EditorGUI.EndChangeCheck()) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Placement"); tiler.placement = SimpleTiler.placement; } } EditorTools.DrawLine(0.5f, 2.5f, 2.5f); } // Count { EditorTools.Label("Count:", "The number of columns and rows."); GUI.backgroundColor = Color.grey; GUILayout.BeginVertical("box"); { GUI.backgroundColor = EditorTools.guiColorBackup; var count = SimpleTiler.tileCount; count.y = EditorTools.Slider("Rows", "The number tiles to be placed on the y-axis for each existing column.", count.y, 1, 20, LabelWidth); count.x = EditorTools.Slider("Columns", "The number tiles to be placed on the x-axis for each existing row.", count.x, 1, 20, LabelWidth); if (SimpleTiler.tileCount.x != count.x) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Count"); tiler.tileCount.x = count.x; tiler.Generate(); } } if (SimpleTiler.tileCount.y != count.y) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Count"); tiler.tileCount.y = count.y; tiler.Generate(); } } } GUILayout.EndVertical(); } // Spacing { EditorTools.Label("Spacing:", "The amount of space between tiles.", 60); GUI.backgroundColor = Color.grey; GUILayout.BeginVertical("box"); { GUI.backgroundColor = EditorTools.guiColorBackup; var spacing = SimpleTiler.tileSpacing; spacing.x = EditorTools.Slider("Horizontal", "The horizontal spacing between tiles.", spacing.x, 0, 10, LabelWidth); spacing.y = EditorTools.Slider("Vertical", "The vertical spacing between tiles.", spacing.y, 0, 10, LabelWidth); if (SimpleTiler.tileSpacing.x != spacing.x) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Spacing"); tiler.tileSpacing.x = spacing.x; tiler.Generate(); } } if (SimpleTiler.tileSpacing.y != spacing.y) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Spacing"); tiler.tileSpacing.y = spacing.y; tiler.Generate(); } } } GUILayout.EndVertical(); } // Size { EditorTools.Label("Size:", "The size of each tile.", 60); GUI.backgroundColor = Color.grey; GUILayout.BeginVertical("box"); { GUI.backgroundColor = EditorTools.guiColorBackup; var size = SimpleTiler.tileSize; size.x = EditorTools.Slider("Width", "The width of each tile.", size.x, 0, 5, LabelWidth); size.y = EditorTools.Slider("Height", "The height of each tile.", size.y, 0, 5, LabelWidth); if (SimpleTiler.tileSize.x != size.x) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Size"); tiler.tileSize.x = size.x; tiler.Generate(); } } if (SimpleTiler.tileSize.y != size.y) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Size"); tiler.tileSize.y = size.y; tiler.Generate(); } } } GUILayout.EndVertical(); } EditorTools.DrawLine(0.5f, 2.5f, 5f); // Colour { var colour = SimpleTiler.tileColor; colour = EditorTools.ColorField("Colour", "The color of each childed sprite of this game object.", colour, true, LabelWidth); if (SimpleTiler.tileColor != colour) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Colour"); tiler.tileColor = colour; tiler.UpdateColours(); } } } // Sorting Layer { GUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); EditorTools.SortingLayerField("Sorting Layer", "The sorting layer to assign to each tile.", _sortingLayerId, EditorStyles.popup, EditorStyles.label, LabelWidth); if (EditorGUI.EndChangeCheck()) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Sorting Layer"); tiler.SetSortingLayer(_sortingLayerId.intValue); } } } GUILayout.EndHorizontal(); GUILayout.Space(1.5f); } // Sorting Order { var sortingOrder = SimpleTiler.sortingOrder; sortingOrder = EditorTools.Slider("Sorting Order", "The sorting order of each tile.", sortingOrder, -50, 50, LabelWidth); if (SimpleTiler.sortingOrder != sortingOrder) { foreach (var t in targets) { var tiler = (t as SimpleTiler)?.GetComponent <SimpleTiler>(); if (tiler is null) { continue; } Undo.RecordObject(tiler, "Sorting Order"); tiler.SetSortingOrder(sortingOrder); } } } //EditorTools.DrawLine(0.5f, 2.5f, 2.5f); //// Tiles //{ // EditorGUI.indentLevel++; // EditorGUIUtility.labelWidth = _labelWidth; // EditorGUILayout.PropertyField(_tiles, new GUIContent("Tiles", "If more than one tile is present, one will picked out at random.")); // EditorGUI.indentLevel--; //} GUILayout.Space(0.5f); } EditorGUILayout.EndVertical(); GUILayout.Space(2.5f); }