void unFreezeMap() { toolEnabled = false; EditorGUILayout.Space(); GUILayout.Label(editorData.mapEditorHeader); EditorGUILayout.BeginVertical("box"); unFreeze = GUILayout.Toggle(unFreeze, "Unfreeze Map", "Button", GUILayout.Height(30)); if (unFreeze) { if (findTileMapParent()) { foreach (Transform child in tileMapParent.transform) { if (child.name.Contains("layer")) { child.gameObject.SetActive(true); } else if (child.gameObject.name == "frozenMap") { DestroyImmediate(child.gameObject); } } } toolEnabled = true; } YuME_sceneGizmoFunctions.displayGizmoGrid(); unFreeze = false; EditorGUILayout.EndVertical(); }
static void OnSceneChanged() { if (currentScene != EditorSceneManager.GetActiveScene().name) { toolEnabled = false; YuME_sceneGizmoFunctions.displayGizmoGrid(); YuTools_Utils.showUnityGrid(true); currentScene = EditorSceneManager.GetActiveScene().name; } }
// ---------------------------------------------------------------------------------------------------- // ----- Draw Scene Tools // ---------------------------------------------------------------------------------------------------- static void OnSceneGUI(SceneView sceneView) { if (toolEnabled) { // ---------------------------------------------------------------------------------------------------- // ----- Draw Scene Editor Tools // ---------------------------------------------------------------------------------------------------- if (selectedTool > 0 && toolEnabled) { controlId = GUIUtility.GetControlID(FocusType.Passive); updateSceneMousePosition(); checkTilePositionIsValid(sceneView.position); YuME_sceneGizmoFunctions.drawBrushGizmo(); } // ---------------------------------------------------------------------------------------------------- // ----- Draw Editor Tool Bar // ---------------------------------------------------------------------------------------------------- YuME_editorSceneUI.drawToolUI(sceneView); // ---------------------------------------------------------------------------------------------------- // ----- Check Keyboard and Mouse Shortcuts // ---------------------------------------------------------------------------------------------------- YuME_keyboardShortcuts.checkKeyboardShortcuts(Event.current); YuME_mouseShorcuts.checkMouseShortcuts(Event.current); foreach (GameObject selected in selectedTiles) { if (selected != null) { YuME_sceneGizmoFunctions.drawSceneGizmoCube(selected.transform.position, Vector3.one, Color.green); } } // ---------------------------------------------------------------------------------------------------- // ----- Momenteray handling of the editor tool bar // ---------------------------------------------------------------------------------------------------- switch (selectedTool) { case toolIcons.defaultTools: YuME_brushFunctions.destroyBrushTile(); break; case toolIcons.brushTool: YuME_brushFunctions.createBrushTile(); selectedTiles.Clear(); break; case toolIcons.pickTool: YuME_brushFunctions.destroyBrushTile(); selectedTiles.Clear(); break; case toolIcons.eraseTool: YuME_brushFunctions.destroyBrushTile(); selectedTiles.Clear(); break; case toolIcons.selectTool: YuME_brushFunctions.destroyBrushTile(); break; case toolIcons.copyTool: YuME_customBrushFunctions.createCopyBrush(false); selectedTool = toolIcons.brushTool; break; case toolIcons.moveTool: YuME_customBrushFunctions.createCopyBrush(true); selectedTool = toolIcons.brushTool; break; case toolIcons.trashTool: YuME_tileFunctions.trashTiles(); selectedTool = previousSelectedTool; break; case toolIcons.customBrushTool: YuME_customBrushFunctions.createCustomBrush(); selectedTool = previousSelectedTool; break; case toolIcons.showGizmos: showGizmos = !showGizmos; YuTools_Utils.disableTileGizmo(showGizmos); selectedTool = previousSelectedTool; break; case toolIcons.gridUpTool: if (Event.current.alt) { gridHeight += 0.25f; } else { gridHeight++; } selectedTool = previousSelectedTool; break; case toolIcons.gridDownTool: if (Event.current.alt) { gridHeight -= 0.25f; } else { gridHeight--; } selectedTool = previousSelectedTool; break; case toolIcons.rotateTool: tileRotation += 90f; selectedTool = previousSelectedTool; break; case toolIcons.flipHorizontalTool: YuME_tileFunctions.flipHorizontal(); selectedTool = previousSelectedTool; break; case toolIcons.flipVerticalTool: YuME_tileFunctions.flipVertical(); selectedTool = previousSelectedTool; break; case toolIcons.isolateTool: YuME_tileFunctions.isolateTilesToggle(); selectedTool = previousSelectedTool; break; case toolIcons.isolateLayerTool: YuME_tileFunctions.isolateLayerToggle(); selectedTool = previousSelectedTool; break; case toolIcons.layerUp: currentLayer++; selectedTool = previousSelectedTool; break; case toolIcons.layerDown: currentLayer--; selectedTool = previousSelectedTool; break; } // ---------------------------------------------------------------------------------------------------- // ----- Check Scene View Inputs for Drawing, Picking etc. // ---------------------------------------------------------------------------------------------------- if (selectedTool > toolIcons.defaultTools) { if ((Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseDown) && Event.current.button == 0 && Event.current.alt == false && Event.current.shift == false && Event.current.control == false && allowTileRedraw) { switch (selectedTool) { case toolIcons.brushTool: switch (currentBrushType) { case brushTypes.standardBrush: addTiles(); break; case brushTypes.customBrush: YuME_customBrushFunctions.pasteCustomBrush(tilePosition); break; case brushTypes.copyBrush: YuME_customBrushFunctions.pasteCopyBrush(tilePosition); break; } break; case toolIcons.pickTool: YuME_tileFunctions.pickTile(tilePosition); break; case toolIcons.eraseTool: eraseTiles(); break; case toolIcons.selectTool: YuME_tileFunctions.selectTile(tilePosition); break; } allowTileRedraw = false; } else if ((Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseDown) && Event.current.button == 0 && Event.current.alt == false && Event.current.shift == true && Event.current.control == false && allowTileRedraw) { switch (selectedTool) { case toolIcons.brushTool: eraseTiles(); break; } allowTileRedraw = false; } else if ((Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseDown) && Event.current.button == 0 && Event.current.alt == false && Event.current.shift == false && Event.current.control == true && allowTileRedraw) { switch (selectedTool) { case toolIcons.brushTool: YuME_tileFunctions.pickTile(tilePosition); break; case toolIcons.selectTool: YuME_tileFunctions.deSelectTile(tilePosition); break; } allowTileRedraw = false; } HandleUtility.AddDefaultControl(controlId); } if (showGizmos) { if (selectedTiles.Count > 0) { foreach (GameObject tile in selectedTiles) { YuME_sceneGizmoFunctions.handleInfo data; data.tileName = tile.name; data.layer = tile.transform.parent.name; data.grid = tile.transform.position.y; YuME_sceneGizmoFunctions.drawTileInfo(tile.transform.position, data); } } } // ---------------------------------------------------------------------------------------------------- // ----- Scene Housekeeping // ---------------------------------------------------------------------------------------------------- YuME_brushFunctions.updateBrushPosition(); repaintSceneView(); previousSelectedTool = selectedTool; } }
void mainGUI() { if (Event.current != null) { // ---------------------------------------------------------------------------------------------------- // ----- Check Keyboard and Mouse Shortcuts // ---------------------------------------------------------------------------------------------------- YuME_keyboardShortcuts.checkKeyboardShortcuts(Event.current); YuME_mouseShorcuts.checkMouseShortcuts(Event.current); SceneView.RepaintAll(); } EditorGUILayout.Space(); GUILayout.Label(editorData.mapEditorHeader); EditorGUILayout.BeginVertical("box"); if (GUILayout.Button("Get the full version of YuME", GUILayout.Height(30))) { Application.OpenURL("http://u3d.as/DrF"); } EditorGUILayout.BeginHorizontal(); toolEnabled = GUILayout.Toggle(toolEnabled, "Enable YuME", "Button", GUILayout.Height(30)); if (_toolEnabled != toolEnabled) { if (!toolEnabled) { YuTools_Utils.showUnityGrid(true); YuME_tileFunctions.restoreIsolatedGridTiles(); YuME_tileFunctions.restoreIsolatedLayerTiles(); } else { setTileBrush(0); YuTools_Utils.showUnityGrid(false); } SceneView.RepaintAll(); } _toolEnabled = toolEnabled; openConfig = GUILayout.Toggle(openConfig, editorData.configButton, "Button", GUILayout.Width(30), GUILayout.Height(30)); if (openConfig == true) { YuME_editorConfig editorConfig = EditorWindow.GetWindow <YuME_editorConfig>(true, "Editor Config"); editorConfig.titleContent.text = "Editor Config"; } openConfig = false; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); gridDimensions = EditorGUILayout.Vector2Field("Grid Dimensions", gridDimensions); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Grid Height: " + gridHeight.ToString()); GUILayout.Label("Brush Size: (" + brushSize.x.ToString() + "," + brushSize.y.ToString() + "," + brushSize.z.ToString() + ")"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Pick The Tile Set To Use", EditorStyles.boldLabel); currentTileSetIndex = EditorGUILayout.Popup("Choose Tileset", currentTileSetIndex, tileSetNames); if (currentTileSetIndex != _currentTileSetIndex) { loadPreviewTiles(); } if (GUILayout.Button("Reload Available Tilesets", GUILayout.Height(30))) { importTileSets(true); loadCustomBrushes(); loadPreviewTiles(); // this is in the wrong place - it needs to be triggered when the user picks a new tileset } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); string[] buttonLabels = new string[] { "Tileset Brushes", "Custom Brushes" }; brushPallete = (brushOptions)GUILayout.SelectionGrid( (int)brushPallete, buttonLabels, 2, EditorStyles.toolbarButton ); EditorGUILayout.EndVertical(); drawTilePreviews(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Tile Previw Columns", EditorStyles.boldLabel); tilePreviewColumnWidth = EditorGUILayout.IntSlider(tilePreviewColumnWidth, 1, 10); EditorGUILayout.EndVertical(); updateGridColors(); YuME_sceneGizmoFunctions.displayGizmoGrid(); _currentTileSetIndex = currentTileSetIndex; }