/// <summary> /// Lets the Editor handle an event in the scene view. /// </summary> private void OnSceneGUI() { if (state == Modes.Idle) { return; } HouseController hc = (HouseController)target; if (input == null) { input = new EditorMouseInput(hc.transform); } // if UpdateHitPosition return true we should update the scene views so that the marker will update in real time if (input.UpdateHitPosition()) { SceneView.RepaintAll(); } // Calculate the location of the marker based on the location of the mouse RecalculateMarkerPosition(); // get a reference to the current event Event current = Event.current; // if the mouse is positioned over the layer allow drawing actions to occur if (this.IsMouseOnLayer()) { // if mouse down or mouse drag event occurred if (current.type == EventType.MouseDown || current.type == EventType.MouseDrag || current.type == EventType.MouseUp) { if (current.button == 1 && (current.type == EventType.MouseUp)) { switch (state) { case Modes.PlaceCell: PlaceCell(hc, input.GetCellPositionFromMouseLocation()); break; case Modes.RemoveCell: RemoveCell(hc, input.GetCellPositionFromMouseLocation()); break; case Modes.PlaceWindow: PlaceWall(hc, input.GetWallPositionFromMouseLocation(), hc.WindowPrefab); break; case Modes.PlaceThickWall: PlaceWall(hc, input.GetWallPositionFromMouseLocation(), hc.ThickWallPrefab); break; case Modes.PlaceEntrance: PlaceWall(hc, input.GetWallPositionFromMouseLocation(), hc.EntrancePrefab); break; case Modes.PlaceGarage: PlaceWall(hc, input.GetWallPositionFromMouseLocation(), hc.GaragePrefab); break; } current.Use(); } } } /* * Handles.BeginGUI(); * GUI.Label(new Rect(10, Screen.height - 90, 100, 100), "LMB: Draw"); * GUI.Label(new Rect(10, Screen.height - 105, 100, 100), "RMB: Erase"); * Handles.EndGUI(); */ }
/// <summary> /// Lets the Editor handle an event in the scene view. /// </summary> private void OnSceneGUI() { if(state==Modes.Idle) return; HouseController hc = (HouseController) target; if(input==null) input = new EditorMouseInput(hc.transform); // if UpdateHitPosition return true we should update the scene views so that the marker will update in real time if (input.UpdateHitPosition()) { SceneView.RepaintAll(); } // Calculate the location of the marker based on the location of the mouse RecalculateMarkerPosition(); // get a reference to the current event Event current = Event.current; // if the mouse is positioned over the layer allow drawing actions to occur if (this.IsMouseOnLayer()) { // if mouse down or mouse drag event occurred if (current.type == EventType.MouseDown || current.type == EventType.MouseDrag || current.type==EventType.MouseUp) { if (current.button == 1 && (current.type==EventType.MouseUp)) { switch(state) { case Modes.PlaceCell: PlaceCell(hc,input.GetCellPositionFromMouseLocation()); break; case Modes.RemoveCell: RemoveCell(hc,input.GetCellPositionFromMouseLocation()); break; case Modes.PlaceWindow: PlaceWall(hc,input.GetWallPositionFromMouseLocation(), hc.WindowPrefab); break; case Modes.PlaceThickWall: PlaceWall(hc,input.GetWallPositionFromMouseLocation(), hc.ThickWallPrefab); break; case Modes.PlaceEntrance: PlaceWall(hc,input.GetWallPositionFromMouseLocation(), hc.EntrancePrefab); break; case Modes.PlaceGarage: PlaceWall(hc,input.GetWallPositionFromMouseLocation(), hc.GaragePrefab); break; } current.Use(); } } } /* Handles.BeginGUI(); GUI.Label(new Rect(10, Screen.height - 90, 100, 100), "LMB: Draw"); GUI.Label(new Rect(10, Screen.height - 105, 100, 100), "RMB: Erase"); Handles.EndGUI(); */ }