private void OnButton_Replace() { // Verify inputs! if (this.sourceBrush == null) { EditorUtility.DisplayDialog( TileLang.ParticularText("Error", "No source brush specified"), TileLang.Text("Please select source brush to find tiles with."), TileLang.ParticularText("Action", "Close") ); return; } if (this.sourceBrush == this.replacementBrush) { EditorUtility.DisplayDialog( TileLang.ParticularText("Error", "Source and replacement brushes are the same"), TileLang.ParticularText("Error", "Cannot find and replace with same brush."), TileLang.ParticularText("Action", "Close") ); return; } // Perform find and replace. if (this.OnFindReplace != null) { this.OnFindReplace(this.targetSystems, this.sourceBrush, this.replacementBrush); } }
public static void SortTileSystemsDescending() { var tileSystems = EditorTileSystemUtility.AllTileSystemsInScene; Undo.RecordObjects(tileSystems.Cast <Object>().ToArray(), TileLang.ParticularText("Action", "Reorder Tile Systems")); ApplySceneOrders(tileSystems.OrderByDescending(system => system.name)); }
private void DrawHelpButton() { GUILayout.Space(33); Rect position = new Rect(Window.position.width - 37, 2, 34, 26); using (var helpMenuContent = ControlContent.Basic( RotorzEditorStyles.Skin.ContextHelp, TileLang.ParticularText("Action", "Help") )) { if (EditorInternalUtility.DropdownMenu(position, helpMenuContent, RotorzEditorStyles.Instance.FlatButton)) { var helpMenu = new EditorMenu(); helpMenu.AddCommand(TileLang.ParticularText("Action", "Show Tips")) .Checked(ControlContent.TrailingTipsVisible) .Action(() => { ControlContent.TrailingTipsVisible = !ControlContent.TrailingTipsVisible; }); --position.y; helpMenu.ShowAsDropdown(position); } } }
private void OnGUI_ListButtons() { var projectSettings = ProjectSettings.Instance; GUILayout.BeginHorizontal(); if (GUILayout.Button(TileLang.ParticularText("Action|Select", "All"), ExtraEditorStyles.Instance.BigButton)) { this.CategorySelection.Clear(); foreach (int number in projectSettings.CategoryIds) { this.CategorySelection.Add(number); } } if (GUILayout.Button(TileLang.ParticularText("Action|Select", "None"), ExtraEditorStyles.Instance.BigButton)) { this.CategorySelection.Clear(); } if (GUILayout.Button(TileLang.ParticularText("Action|Select", "Invert"), ExtraEditorStyles.Instance.BigButton)) { var invertedSelection = projectSettings.CategoryIds .Where(number => !this.CategorySelection.Contains(number)); this.CategorySelection = new HashSet <int>(invertedSelection); } GUILayout.EndHorizontal(); }
private void OnButton_DeletePreset() { if (this.selectedPreset == null) { EditorUtility.DisplayDialog( TileLang.Text("Error"), TileLang.ParticularText("Error", "Cannot delete a default preset."), TileLang.ParticularText("Action", "Close") ); } else if (EditorUtility.DisplayDialog( TileLang.ParticularText("Action", "Delete Preset"), string.Format( /* 0: name of the preset */ TileLang.ParticularText("Error", "Do you want to delete the preset '{0}'?"), this.currentPreset.name ), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { // Remove the selected preset asset. TileSystemPresetUtility.DeletePreset(this.selectedPreset); // Select the default preset. this.SetSelectedPreset(""); } }
/// <inheritdoc/> public override void OnAdvancedToolOptionsGUI() { this.PlopLocation = (Location)EditorGUILayout.EnumPopup(TileLang.ParticularText("Property", "Location"), this.PlopLocation); ++EditorGUI.indentLevel; switch (this.PlopLocation) { case Location.GroupInsideTileSystem: this.PlopGroupName = EditorGUILayout.TextField(TileLang.ParticularText("Property", "Group Name"), this.PlopGroupName); break; } --EditorGUI.indentLevel; ExtraEditorGUI.SeparatorLight(); // Repaint scene views when options are changed so that handles updated. EditorGUI.BeginChangeCheck(); this.DisableCycleFunction = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Disable cycle function"), this.DisableCycleFunction); this.InteractWithActiveSystemOnly = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Interact with active system only"), this.InteractWithActiveSystemOnly); this.HideWireframeOutline = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Hide wireframe outline"), this.HideWireframeOutline); if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } }
public void EndEditingName(bool accept) { if (!this.IsEditingName) { throw new InvalidOperationException("Not actually renaming a tile system!"); } if (accept) { var tileSystem = this.entries[this.renameIndex].TileSystem; string currentName = tileSystem.gameObject.name; if (!string.IsNullOrEmpty(this.renameFieldText) && this.renameFieldText != currentName) { string actionDescription = string.Format( /* 0: current name of the tile system */ TileLang.ParticularText("Action", "Rename {0}"), currentName ); Undo.RecordObject(tileSystem.gameObject, actionDescription); tileSystem.gameObject.name = this.renameFieldText; } } this.IsEditingName = false; GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; }
internal static void DeleteBrush(Brush brush, bool selectParentTileset) { var brushRecord = BrushDatabase.Instance.FindRecord(brush); if (brushRecord == null) { return; } RotorzEditorGUI.ClearControlFocus(); if (EditorUtility.DisplayDialog( TileLang.ParticularText("Action", "Delete Brush"), string.Format( /* 0: name of brush */ TileLang.Text("Deleting a brush that has been previously used in a tile system may cause damage to that tile system.\n\n'{0}'\n\nDo you really want to delete this brush?"), brushRecord.DisplayName ), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { // Determine whether tileset should be selected in designer. var designerWindow = RotorzWindow.GetInstance <DesignerWindow>(); if (designerWindow != null && ReferenceEquals(brushRecord.Brush, designerWindow.SelectedObject)) { designerWindow.SelectedObject = selectParentTileset && brushRecord.Brush is TilesetBrush ? (brushRecord.Brush as TilesetBrush).Tileset : null; } BrushUtility.DeleteBrush(brushRecord.Brush); } }
/// <summary> /// Display user interface to clear a tile system. /// </summary> /// <param name="system">Tile system.</param> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="system"/> is <c>null</c>. /// </exception> internal static void Command_Clear(TileSystem system) { if (system == null) { throw new ArgumentNullException("system"); } if (!EditorUtility.DisplayDialog( TileLang.ParticularText("Action", "Clear Tiles"), string.Format( /* 0: name of tile system */ TileLang.Text("Do you really want to clear all tiles from '{0}'?"), system.name ), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { return; } // Register undo event. Undo.RegisterFullObjectHierarchyUndo(system.gameObject, TileLang.ParticularText("Action", "Clear Tiles")); // Erase all tiles from selected system. system.EraseAllTiles(); }
private void DrawToolbar() { GUILayout.BeginHorizontal(EditorStyles.toolbar); if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Create Tile System")), EditorStyles.toolbarButton)) { CreateTileSystemWindow.ShowWindow(); GUIUtility.ExitGUI(); } GUILayout.FlexibleSpace(); if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Build")), RotorzEditorStyles.Instance.ToolbarButtonPadded)) { BuildUtility.BuildScene(); GUIUtility.ExitGUI(); } EditorGUILayout.Space(); if (GUILayout.Button(RotorzEditorStyles.Skin.SortAsc, EditorStyles.toolbarButton)) { EditorTileSystemUtility.SortTileSystemsAscending(); this.Repaint(); GUIUtility.ExitGUI(); } if (GUILayout.Button(RotorzEditorStyles.Skin.SortDesc, EditorStyles.toolbarButton)) { EditorTileSystemUtility.SortTileSystemsDescending(); this.Repaint(); GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); }
/// <inheritdoc/> public override void OnExtendedPropertiesGUI() { var emptyBrush = Brush as EmptyBrush; using (var content = ControlContent.WithTrailableTip( TileLang.ParticularText("Property", "Always Add Container"), TileLang.Text("Add tile container object even when not needed by brush.") )) { emptyBrush.alwaysAddContainer = EditorGUILayout.ToggleLeft(content, emptyBrush.alwaysAddContainer); ExtraEditorGUI.TrailingTip(content); } using (var content = ControlContent.WithTrailableTip( TileLang.ParticularText("Property", "Add Collider"), TileLang.Text("Automatically adds box collider to painted tile.") )) { emptyBrush.addCollider = EditorGUILayout.ToggleLeft(content, emptyBrush.addCollider); if (emptyBrush.addCollider) { ++EditorGUI.indentLevel; emptyBrush.colliderType = (ColliderType)EditorGUILayout.EnumPopup(emptyBrush.colliderType); --EditorGUI.indentLevel; } ExtraEditorGUI.TrailingTip(content); } }
/// <summary> /// Sets label of a specific category. /// </summary> /// <param name="id">Identifies the category.</param> /// <param name="label">The new category label.</param> /// <exception cref="System.ArgumentOutOfRangeException"> /// If <paramref name="id"/> is zero or a negative value. /// </exception> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="label"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentException"> /// If <paramref name="label"/> is an empty string. /// </exception> /// <seealso cref="AddCategory(string)"/> public void SetCategoryLabel(int id, string label) { if (id <= 0) { throw new ArgumentOutOfRangeException("id", id, (string)null); } if (label == null) { throw new ArgumentNullException("label"); } if (label == "") { throw new ArgumentException("Was empty.", "label"); } Undo.RecordObject(this, TileLang.ParticularText("Action", "Set Category Label")); BrushCategoryInfo info; if (!this.categoryMap.TryGetValue(id, out info)) { info = new BrushCategoryInfo(id); this.categories.Add(info); this.categoryMap[id] = info; } info.Label = label; EditorUtility.SetDirty(this); ++this.CategoryRevisionCounter; }
/// <inheritdoc/> protected override void DoEnable() { this.titleContent = new GUIContent(string.Format( /* 0: name of product */ TileLang.Text("Preferences - {0}"), ProductInfo.Name )); this.InitialSize = this.minSize = new Vector2(500, 342); this.maxSize = new Vector2(500, 10000); this.wantsMouseMove = true; this.tabs = new GUIContent[] { ControlContent.Basic(TileLang.ParticularText("Preferences|TabLabel", "Tools")), ControlContent.Basic(TileLang.ParticularText("Preferences|TabLabel", "Painting")), ControlContent.Basic(TileLang.ParticularText("Preferences|TabLabel", "Grid")), ControlContent.Basic(TileLang.ParticularText("Preferences|TabLabel", "Misc")) }; this.scrolling = new Vector2[this.tabs.Length]; this.toolsAdaptor = new GenericListAdaptor <ToolBase>(ToolManager.Instance.toolsInUserOrder, this.DrawAvailableToolEntry, 22); this.GatherLocaleOptions(); }
private void DrawPaintingTab() { RtsPreferences.EraseEmptyChunksPreference.Value = (EraseEmptyChunksPreference)EditorGUILayout.EnumPopup(TileLang.Text("Erase empty chunks"), RtsPreferences.EraseEmptyChunksPreference); ExtraEditorGUI.SeparatorLight(); RtsPreferences.ToolPreferredNozzleIndicator.Value = (NozzleIndicator)EditorGUILayout.EnumPopup(TileLang.Text("Preferred nozzle indicator"), RtsPreferences.ToolPreferredNozzleIndicator); ++EditorGUI.indentLevel; { RtsPreferences.ToolWireframeColor.Value = EditorGUILayout.ColorField(TileLang.ParticularText("RenderMode", "Wireframe"), RtsPreferences.ToolWireframeColor); RtsPreferences.ToolShadedColor.Value = EditorGUILayout.ColorField(TileLang.ParticularText("RenderMode", "Shaded"), RtsPreferences.ToolShadedColor); } --EditorGUI.indentLevel; ExtraEditorGUI.SeparatorLight(); RtsPreferences.ToolImmediatePreviews.Value = EditorGUILayout.ToggleLeft(TileLang.Text("Display immediate previews"), RtsPreferences.ToolImmediatePreviews); EditorGUI.BeginDisabledGroup(!RtsPreferences.ToolImmediatePreviews); ++EditorGUI.indentLevel; { RtsPreferences.ToolImmediatePreviewsTintColor.Value = EditorGUILayout.ColorField(TileLang.Text("Preview Tint"), RtsPreferences.ToolImmediatePreviewsTintColor); RtsPreferences.ToolImmediatePreviewsSeeThrough.Value = EditorGUILayout.Toggle(TileLang.Text("See-through previews"), RtsPreferences.ToolImmediatePreviewsSeeThrough); ExtraEditorGUI.TrailingTip(TileLang.Text("Hold control when painting to temporarily see-through.")); } --EditorGUI.indentLevel; EditorGUI.EndDisabledGroup(); }
private void DrawProceduralField(TilesetBrush brush, Tileset tileset) { using (var content = ControlContent.WithTrailableTip( TileLang.ParticularText("Property", "Procedural"), TileLang.Text("Allows individual atlas brushes to override property of tileset.") )) { // Need to make width of "Procedural" popup shorter. GUILayout.BeginHorizontal(GUILayout.Width(200)); InheritYesNo newProcedural = (InheritYesNo)EditorGUILayout.EnumPopup(content, brush.procedural); if (newProcedural != brush.procedural) { brush.procedural = newProcedural; if (!brush.IsProcedural) { // Ensure that required procedural mesh exists! if (BrushUtility.EnsureTilesetMeshExists(tileset, brush.tileIndex)) { AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(tileset.tileMeshAsset)); } } } Rect position = GUILayoutUtility.GetLastRect(); GUI.Label(new Rect(position.x + position.width, position.y, 100, position.height), "= " + (brush.IsProcedural ? TileLang.Text("Procedural") : TileLang.Text("Non-Procedural")), EditorStyles.miniLabel); GUILayout.EndHorizontal(); ExtraEditorGUI.TrailingTip(content); } }
/// <summary> /// Display user interface to force refresh all plops associated with a tile system. /// </summary> /// <param name="system">Tile system.</param> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="system"/> is <c>null</c>. /// </exception> internal static void Command_RefreshPlops(TileSystem system) { if (system == null) { throw new ArgumentNullException("system"); } if (!EditorUtility.DisplayDialog( TileLang.ParticularText("Action", "Refresh Plops"), string.Format( /* 0: name of tile system */ TileLang.Text("Do you want to force refresh all plops associated with '{0}'?"), system.name ), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { return; } // Refresh all plops which are associated with tile system. foreach (var plop in UnityEngine.Resources.FindObjectsOfTypeAll <PlopInstance>()) { if (plop.Owner == system && plop.Brush != null) { PlopUtility.RefreshPlop(system, plop); } } }
private void DrawStatusPanel() { var tileSystem = target as TileSystem; Handles.BeginGUI(); if (tileSystem.IsEditable) { string title = tileSystem.name; if (tileSystem.Locked) { title += " <color=yellow><b>(" + TileLang.ParticularText("Status", "Locked") + ")</b></color>"; } Rect position = new Rect(0, Screen.height - 21 - 42, 380, 42); GUI.Window(0, position, this._statusPanelWindowFunction, title, RotorzEditorStyles.Instance.StatusWindow); GUI.UnfocusWindow(); } else { Rect position = new Rect(5, Screen.height - 42 - 40, 380, 40); EditorGUI.HelpBox(position, TileLang.Text("Tile system has been built and can no longer be edited."), MessageType.Warning); } Handles.EndGUI(); }
private void ShowRecentHistoryMenu() { var recentHistoryMenu = new EditorMenu(); this.History.Cleanup(); recentHistoryMenu.AddCommand(this.SelectedObject.HistoryName) .Visible(this.SelectedObject != null && this.SelectedObject.Exists) .Checked(true) .Action(this.RecentHistoryMenu_Select, this.SelectedObject); foreach (IHistoryObject recent in this.History.Recent) { if (!ReferenceEquals(recent, this.SelectedObject)) { recentHistoryMenu.AddCommand(recent.HistoryName) .Checked(ReferenceEquals(recent, this.SelectedObject)) .Action(this.RecentHistoryMenu_Select, recent); } } recentHistoryMenu.AddSeparator(); recentHistoryMenu.AddCommand(TileLang.ParticularText("Action", "Clear Recent History")) .Action(() => { this.History.Clear(); }); this._recentHistoryButtonPosition.height -= 2; recentHistoryMenu.ShowAsDropdown(this._recentHistoryButtonPosition); }
private static ControlContent AlignmentContent(string label, SnapAxis axis) { Texture2D icon; string tip; switch (axis.Alignment) { default: case SnapAlignment.Points: icon = RotorzEditorStyles.Skin.SnapPoints; tip = TileLang.ParticularText("SnapAlignment", "Points"); break; case SnapAlignment.Cells: icon = RotorzEditorStyles.Skin.SnapCells; tip = TileLang.ParticularText("SnapAlignment", "Cells"); break; case SnapAlignment.Free: icon = label == "X" ? RotorzEditorStyles.Skin.SnapFreeX : RotorzEditorStyles.Skin.SnapFreeY; tip = TileLang.ParticularText("SnapAlignment", "Free"); break; } return(ControlContent.Basic(icon, tip)); }
private void OnButtonRefresh() { Undo.RegisterFullObjectHierarchyUndo(this.tileSystem.gameObject, TileLang.ParticularText("Action", "Refresh Tiles")); RefreshFlags flags = RefreshFlags.None; if (s_ForceRefreshTiles) { flags |= RefreshFlags.Force; } if (s_UpdateProcedural) { flags |= RefreshFlags.UpdateProcedural; } if (s_PreserveFlags) { flags |= RefreshFlags.PreservePaintedFlags; } if (s_PreserveManualOffset) { flags |= RefreshFlags.PreserveTransform; } this.tileSystem.RefreshAllTiles(flags); this.Close(); }
private void DrawToolbar() { GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginDisabledGroup(PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab || this.targets.Length != 1); if (this.target.IsEditable && GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Build Prefab")), RotorzEditorStyles.Instance.ToolbarButtonPaddedExtra)) { TileSystemCommands.Command_BuildPrefab(this.target); GUIUtility.ExitGUI(); } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); using (var content = ControlContent.Basic( RotorzEditorStyles.Skin.GridToggle, TileLang.ParticularText("Action", "Toggle Grid Display") )) { RtsPreferences.ShowGrid.Value = GUILayout.Toggle(RtsPreferences.ShowGrid, content, RotorzEditorStyles.Instance.ToolbarButtonPadded); } using (var content = ControlContent.Basic( RotorzEditorStyles.Skin.ChunkToggle, TileLang.ParticularText("Action", "Toggle Chunk Display") )) { RtsPreferences.ShowChunks.Value = GUILayout.Toggle(RtsPreferences.ShowChunks, content, RotorzEditorStyles.Instance.ToolbarButtonPadded); } EditorGUILayout.Space(); this.DrawHelpButton(); GUILayout.EndHorizontal(); }
private static string SaveBuildSceneAs() { string currentScenePath = EditorApplication.currentScene.Replace("Assets/", Application.dataPath + "/"); int fileNameIndex = currentScenePath.LastIndexOf('/'); // Prompt user to save built scene. string outputPath; while (true) { // Prompt user to save scene. outputPath = EditorUtility.SaveFilePanel( title: TileLang.ParticularText("Action", "Save Built Scene"), directory: currentScenePath.Substring(0, fileNameIndex), defaultName: currentScenePath.Substring(fileNameIndex + 1).Replace(".unity", "_build.unity"), extension: "unity" ); // Make output path relative to project. outputPath = outputPath.Replace(Application.dataPath, "Assets"); // Attempt to save scene. if (!string.IsNullOrEmpty(outputPath)) { if (outputPath == EditorApplication.currentScene) { if (EditorUtility.DisplayDialog( TileLang.Text("Error"), TileLang.ParticularText("Error", "Cannot overwrite current scene with built scene."), TileLang.ParticularText("Action", "Choose Other"), TileLang.ParticularText("Action", "Cancel") )) { continue; } else { return(null); } } // Ensure that built scene will be placed within "Assets" directory. else if (outputPath.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase)) { break; } } // Allow user to retry! if (!EditorUtility.DisplayDialog( TileLang.Text("Error"), TileLang.ParticularText("Error", "Was unable to save built scene.\n\nWould you like to specify an alternative filename?"), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { return(null); } } return(outputPath); }
private void PopulatePresetMenu(ICustomPopupContext <string> context) { var popup = context.Popup; popup.AddOption(TileLang.ParticularText("Preset Name", "Default: 3D"), context, "F:3D"); popup.AddOption(TileLang.ParticularText("Preset Name", "Default: 2D"), context, "F:2D"); var presets = TileSystemPresetUtility.GetPresets(); if (presets.Length == 0) { return; } popup.AddSeparator(); var presetGroups = presets .OrderBy(preset => preset.name) .GroupBy(preset => TileSystemPresetUtility.IsUserPreset(preset)) .ToArray(); for (int i = 0; i < presetGroups.Length; ++i) { if (i != 0) { popup.AddSeparator(); } foreach (var preset in presetGroups[i]) { popup.AddOption(preset.name, context, TileSystemPresetUtility.GetPresetGUID(preset)); } } }
/// <inheritdoc/> protected override void DoGUI() { this.hasDrawnGUI = true; if (this.tileSystem == null) { return; } GUISkin skin = GUI.skin; GUILayout.Space(15f); ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Prefab Output Path:")); GUILayout.BeginHorizontal(); { this.PrefabOutputPath = RotorzEditorGUI.RelativeAssetPathTextField(GUIContent.none, this.PrefabOutputPath, ".prefab"); if (GUILayout.Button("...", GUILayout.Width(40))) { GUIUtility.keyboardControl = 0; this.PrefabOutputPath = this.DoSelectPrefabPath( TileLang.ParticularText("Action", "Save Prefab Output"), TileLang.Text("Specify path for prefab output"), this.PrefabOutputPath ); } } GUILayout.EndHorizontal(); EditorGUILayout.Space(); ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Data Output Path:")); GUILayout.BeginHorizontal(); { this.DataOutputPath = RotorzEditorGUI.RelativeAssetPathTextField(GUIContent.none, this.DataOutputPath, ".asset"); if (GUILayout.Button("...", GUILayout.Width(40))) { GUIUtility.keyboardControl = 0; this.DataOutputPath = this.DoSelectAssetPath( TileLang.ParticularText("Action", "Save Data Output"), TileLang.Text("Specify path for mesh output"), this.DataOutputPath ); } } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); ExtraEditorGUI.Separator(marginBottom: 10); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); this.OnGUI_Buttons(); GUILayout.Space(5f); } GUILayout.EndHorizontal(); GUILayout.Space(8f); }
private void OnGUI_Buttons() { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(TileLang.ParticularText("Action", "Save"), ExtraEditorStyles.Instance.BigButton, RotorzEditorStyles.ContractWidth)) { if (this.brush != null && this.brushTab != null) { this.brush.UserFlagLabels = this.brushTab.FlagLabels; EditorUtility.SetDirty(this.brush); } ProjectSettings.Instance.FlagLabels = this.projectTab.FlagLabels; DesignerWindow.RepaintWindow(); this.Close(); GUIUtility.ExitGUI(); } if (GUILayout.Button(TileLang.ParticularText("Action", "Cancel"), ExtraEditorStyles.Instance.BigButton, RotorzEditorStyles.ContractWidth)) { this.Close(); GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); }
private void DoBuild() { this.PrefabOutputPath = this.PrefabOutputPath.Trim(); this.DataOutputPath = this.DataOutputPath.Trim(); string resolvedPrefabPath = this.GetResolvedPrefabPath(); string resolvedDataPath = this.GetResolvedDataPath(); if (this.ValidateAssetPath("prefab", resolvedPrefabPath) && this.ValidateAssetPath("data asset", resolvedDataPath)) { // Confirm action with user if prefab and/or data asset already exist. bool outputPrefabAlreadyExists = File.Exists(Path.Combine(Directory.GetCurrentDirectory(), resolvedPrefabPath)); bool outputDataAlreadyExists = File.Exists(Path.Combine(Directory.GetCurrentDirectory(), resolvedDataPath)); if (outputPrefabAlreadyExists || outputDataAlreadyExists) { if (!EditorUtility.DisplayDialog( TileLang.Text("Warning, Output prefab or data asset already exists!"), TileLang.Text("Do you really want to overwrite?"), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { return; } } BuildUtility.BuildPrefab(this.TileSystem, resolvedDataPath, resolvedPrefabPath); this.Close(); } }
public static bool ReorderTileSystem(TileSystem system, int sceneOrder) { if (system.sceneOrder == sceneOrder) { return(false); } var tileSystems = EditorTileSystemUtility.AllTileSystemsInScene; if (!tileSystems.Contains(system)) { return(false); } // Adjust scene order of tile systems. foreach (var tileSystem in tileSystems) { if (tileSystem.sceneOrder >= sceneOrder) { Undo.RecordObject(tileSystem, TileLang.ParticularText("Action", "Reorder Tile Systems")); ++tileSystem.sceneOrder; } } system.sceneOrder = sceneOrder; ApplySceneOrders(tileSystems.OrderBy(s => s.sceneOrder)); return(true); }
private bool ValidateInputs(string tilesetName) { if (!this.ValidateAssetName(tilesetName)) { return(false); } foreach (var tilesetRecord in BrushDatabase.Instance.TilesetRecords) { if (tilesetRecord.DisplayName == tilesetName) { EditorUtility.DisplayDialog( TileLang.Text("Tileset already exists"), TileLang.Text("Please specify unique name for tileset."), TileLang.ParticularText("Action", "OK") ); return(false); } } if (this.tilesetTexture == null) { EditorUtility.DisplayDialog( TileLang.Text("Texture was not specified"), TileLang.Text("Texture must be specified before creating tileset."), TileLang.ParticularText("Action", "OK") ); return(false); } return(true); }
private bool ValidateInputs(string brushName, Brush targetBrush) { if (!this.ValidateUniqueAssetName(brushName)) { return(false); } if (targetBrush == null) { EditorUtility.DisplayDialog( TileLang.Text("Target brush was not specified"), TileLang.Text("Select the brush that you would like to create an alias of."), TileLang.ParticularText("Action", "Close") ); return(false); } var targetBrushDescriptor = BrushUtility.GetDescriptor(targetBrush.GetType()); if (targetBrushDescriptor == null || !targetBrushDescriptor.SupportsAliases) { EditorUtility.DisplayDialog( TileLang.Text("Unable to create alias brush"), string.Format( /* 0: class of target brush */ TileLang.Text("No alias designer was registered for '{0}'"), targetBrush.GetType().FullName ), TileLang.ParticularText("Action", "Close") ); return(false); } return(true); }
private void OnGUI_BrushSelection() { if (this.arrowStyle == null) { this.arrowStyle = new GUIStyle(GUI.skin.label); this.arrowStyle.stretchHeight = true; this.arrowStyle.alignment = TextAnchor.MiddleCenter; } GUILayout.BeginVertical(); ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Source Brush"), RotorzEditorStyles.Instance.BoldLabel); { this.sourceBrush = RotorzEditorGUI.BrushField(this.sourceBrush); EditorGUILayout.Space(); this.sourceBrush = this.DrawBrushPreviewField(this.sourceBrush); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.Label("=>", this.arrowStyle); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Replacement Brush"), RotorzEditorStyles.Instance.BoldLabel); { this.replacementBrush = RotorzEditorGUI.BrushField(this.replacementBrush); EditorGUILayout.Space(); this.replacementBrush = this.DrawBrushPreviewField(this.replacementBrush); } GUILayout.EndVertical(); }