private void OnEnable() { Instance = this; LoadEditorModeOptions(); visual = new EditorViewGridVisualisation(); SceneView.onSceneGUIDelegate -= onSceneGUI; SceneView.onSceneGUIDelegate += onSceneGUI; EditorApplication.update -= onEditorApplicationUpdate; EditorApplication.update += onEditorApplicationUpdate; }
public override void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual) { base.OnSceneViewGUI(view, backend, visual); if (backend.selectedMaze != null) { EditorVisualUtils.HandlesDrawGrid(backend.selectedMaze); } }
private bool CheckIfTileIsValidPathElement(MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual) { var tilePosition = visual.currentTilePosition; if (!backend.selectedMaze.Units.Any((u) => u.GridID.Equals(tilePosition))) { return(false); } if (pathToEdit.PathAsLinkedList != null && pathToEdit.PathAsLinkedList.Count == 0) { return(true); } var lastElement = pathToEdit.PathAsLinkedList.Last; var gridIdOfLastElement = lastElement.Value.Unit.GridID; if (tilePosition == gridIdOfLastElement) { return(false); } if (lastElement.Previous != null) { var gridIdOfPreviousElement = lastElement.Previous.Value.Unit.GridID; if (gridIdOfPreviousElement == tilePosition) { return(false); } } var deltaBetweenLastAndCurrent = tilePosition - gridIdOfLastElement; var absDelta = deltaBetweenLastAndCurrent.SqrMagnitude(); if (absDelta > 1) { return(false); } return(true); }
public override void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual) { if (pathToEdit == null) { return; } tilePositionIsValid = CheckIfTileIsValidPathElement(backend, visual); }
public override void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual) { base.OnSceneViewGUI(view, backend, visual); }
public virtual void ProcessEvent(Event evt, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual) { if (backend == null) { Debug.Log("backend null"); } this.backend = backend; controlId = GUIUtility.GetControlID(FocusType.Passive); if (evt.type == EventType.MouseDown) { if (dragging) { DragEnds(); } Click(evt, evt.button); } if (evt.type == EventType.MouseDrag) { Drag(evt, evt.button); } if (evt.type == EventType.MouseUp) { if (dragging) { DragEnds(); } Click(evt, evt.button); } }
public virtual void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual) { visual.pushHandleColor(); Handles.color = tileHighlighting; visual.popHandleColor(); }