public bool HandleShortcuts() { bool bShiftDown = Input.GetKey(KeyCode.LeftShift); bool bCtrlDown = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); // ESCAPE CLEARS ACTIVE TOOL OR SELECTION if (Input.GetKeyUp(KeyCode.Escape)) { if (context.ToolManager.HasActiveTool(0) || context.ToolManager.HasActiveTool(1)) { context.ToolManager.DeactivateTool(0); context.ToolManager.DeactivateTool(1); } else if (context.Scene.Selected.Count > 0) { context.Scene.ClearSelection(); } return(true); } else if (Input.GetKeyUp(KeyCode.A)) { if (PanelGroup != null) { PanelGroup.SelectModulo(PanelGroup.Selected + 1); } return(true); } else if (Input.GetKeyUp(KeyCode.S)) { if (PanelGroup != null) { PanelGroup.SelectModulo(PanelGroup.Selected - 1); } return(true); // CENTER TARGET (??) } else if (Input.GetKeyUp(KeyCode.C)) { Ray3f cursorRay = context.MouseController.CurrentCursorWorldRay(); AnyRayHit hit = null; if (context.Scene.FindSceneRayIntersection(cursorRay, out hit)) { context.ActiveCamera.Manipulator().ScenePanFocus(context.Scene, context.ActiveCamera, hit.hitPos, true); } return(true); // TOGGLE FRAME TYPE } else if (Input.GetKeyUp(KeyCode.F)) { FrameType eCur = context.TransformManager.ActiveFrameType; context.TransformManager.ActiveFrameType = (eCur == FrameType.WorldFrame) ? FrameType.LocalFrame : FrameType.WorldFrame; return(true); // DROP A COPY } else if (Input.GetKeyUp(KeyCode.D)) { foreach (SceneObject so in context.Scene.Selected) { SceneObject copy = so.Duplicate(); if (copy != null) { // [TODO] could have a lighter record here because we can just re-run Duplicate() ? context.Scene.History.PushChange( new AddSOChange() { scene = context.Scene, so = copy }); context.Scene.History.PushInteractionCheckpoint(); } } return(true); // VISIBILITY (V HIDES, SHIFT+V SHOWS) } else if (Input.GetKeyUp(KeyCode.V)) { // show/hide (should be abstracted somehow?? instead of directly accessing GOs?) if (bShiftDown) { foreach (SceneObject so in context.Scene.SceneObjects) { so.RootGameObject.Show(); } } else { foreach (SceneObject so in context.Scene.Selected) { so.RootGameObject.Hide(); } context.Scene.ClearSelection(); } return(true); // UNDO } else if (bCtrlDown && Input.GetKeyUp(KeyCode.Z)) { context.Scene.History.InteractiveStepBack(); return(true); // REDO } else if (bCtrlDown && Input.GetKeyUp(KeyCode.Y)) { context.Scene.History.InteractiveStepForward(); return(true); // FILE OPEN } else if (bCtrlDown && Input.GetKeyUp(KeyCode.O)) { var cp = new FileOpenCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; context.PushCockpit(cp); return(true); // FILE SAVE } else if (bCtrlDown && Input.GetKeyUp(KeyCode.S)) { var cp = new FileSaveCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; context.PushCockpit(cp); return(true); // FILE IMPORT } else if (bCtrlDown && Input.GetKeyUp(KeyCode.I)) { var cp = new FileImportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; context.PushCockpit(cp); return(true); // FILE EXPORT } else if (bCtrlDown && Input.GetKeyUp(KeyCode.E)) { var cp = new FileExportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; context.PushCockpit(cp); return(true); // APPLY CURRENT TOOL IF POSSIBLE } else if (Input.GetKeyUp(KeyCode.Return)) { if (((context.ActiveInputDevice & InputDevice.Mouse) != 0) && context.ToolManager.HasActiveTool(ToolSide.Right) && context.ToolManager.ActiveRightTool.CanApply) { context.ToolManager.ActiveRightTool.Apply(); } return(true); } else if (Input.GetKeyUp(KeyCode.Alpha1)) { context.ToolManager.SetActiveToolType(SnapDrawPrimitivesTool.Identifier, 1); context.ToolManager.ActivateTool(1); return(true); } else if (Input.GetKeyUp(KeyCode.Alpha2)) { context.ToolManager.SetActiveToolType(DrawTubeTool.Identifier, 1); context.ToolManager.ActivateTool(1); return(true); } else if (Input.GetKeyUp(KeyCode.Alpha3)) { context.ToolManager.SetActiveToolType(DrawCurveTool.Identifier, 1); context.ToolManager.ActivateTool(1); return(true); } else if (Input.GetKeyUp(KeyCode.S)) { return(true); } else if (Input.GetKeyUp(KeyCode.Equals)) { if (Application.isEditor) { string sName = UniqueNames.GetNext("Screenshot"); sName = "C:\\scratch\\" + sName + ".png"; ScreenCapture.CaptureScreenshot(sName, 4); Debug.Log("Wrote screenshot " + sName); } return(true); } else { return(false); } }
void AddMenuButtonsGroup(Cockpit cockpit) { HUDButton importButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, //0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging "icons/import_v1"); importButton.Name = "import"; cockpit.AddUIElement(importButton, true); importButton.OnClicked += (s, e) => { var cp = new FileImportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton exportButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, //0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging convenience "icons/export_v1"); UnityUtil.TranslateInFrame(exportButton.RootGameObject, 0, -0.055f, 0, CoordSpace.WorldCoords); exportButton.Name = "export"; cockpit.AddUIElement(exportButton, true); exportButton.OnClicked += (s, e) => { var cp = new FileExportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton janusButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, //0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging convenience "cockpit_icons/menu_buttons/janus_v1"); UnityUtil.TranslateInFrame(janusButton.RootGameObject, 0, 2.0f * -0.055f, 0, CoordSpace.WorldCoords); janusButton.Name = "export"; cockpit.AddUIElement(janusButton, true); janusButton.OnClicked += (s, e) => { var cp = new JanusVRExportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton loadButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, // 0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging convenience "icons/load_v1"); UnityUtil.TranslateInFrame(loadButton.RootGameObject, 0.12f, 0, 0, CoordSpace.WorldCoords); loadButton.Name = "load"; cockpit.AddUIElement(loadButton, true); loadButton.OnClicked += (s, e) => { var cp = new FileLoadSceneCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton saveButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, // 0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging "icons/save_v1"); UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.12f, -0.055f, 0, CoordSpace.WorldCoords); saveButton.Name = "save"; cockpit.AddUIElement(saveButton, true); saveButton.OnClicked += (s, e) => { var cp = new FileSaveSceneCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton newButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, "icons/new_v1"); UnityUtil.TranslateInFrame(newButton.RootGameObject, 0.24f, 0, 0, CoordSpace.WorldCoords); newButton.Name = "new"; cockpit.AddUIElement(newButton, true); newButton.OnClicked += (s, e) => { cockpit.Context.NewScene(true); }; HUDButton quitButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, "icons/quit_v1"); UnityUtil.TranslateInFrame(quitButton.RootGameObject, 0.24f, -0.055f, 0, CoordSpace.WorldCoords); quitButton.Name = "quit"; cockpit.AddUIElement(quitButton, true); quitButton.OnClicked += (s, e) => { FPlatform.QuitApplication(); }; }