//====================================================================================================================================== // Scene Editing View //====================================================================================================================================== void OnSceneGUI() { // if (!meshRefreshRequested) { if (DrawBoxSelection()) { NPVoxAnimHelpWindow.GetWindow().SetContext(NPVoxAnimHelpWindow.Context.Box); } else if (DrawBoneSelection()) { NPVoxAnimHelpWindow.GetWindow().SetContext(NPVoxAnimHelpWindow.Context.Bone); } else if (viewModel.SelectedTransformer != null) { NPVoxAnimHelpWindow.GetWindow().SetContext(NPVoxAnimHelpWindow.Context.Misc); } else { NPVoxAnimHelpWindow.GetWindow().SetContext(NPVoxAnimHelpWindow.Context.None); } } DrawSceneEditTools(); // if (!meshRefreshRequested) { DrawSockets(viewModel.SelectedTransformer != null); } //Return focus back to THIS GameObject to be able to continue processing events //This is very important, this part should be outside of the previous condition!!! Selection.activeGameObject = ((MonoBehaviour)target).transform.gameObject; KeyboardShortcuts(); }
public static NPVoxAnimHelpWindow GetWindow() { if (!window) { window = (NPVoxAnimHelpWindow)EditorWindow.GetWindow(typeof(NPVoxAnimHelpWindow), true, "NPVoxAnimHelpWindow Window"); } return(window); }
// =================================================================================================== // Inspector UI // =================================================================================================== public override void OnInspectorGUI() { if (!viewModel.IsPlaying && wasPreview) { // workaround for stupid "getting control 5" exception wasPreview = false; Repaint(); return; } viewModel.ProcessInvalidations(); NPVoxAnimationEditorSession session = ((NPVoxAnimationEditorSession)target); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Close Editor") || !session.animation) { NPVoxAnimationEditor.CloseAnimationEditor(session); } if (GUILayout.Button("Debug")) { viewModel.DebugButton(); } if (GUILayout.Button("Invalidate & Reimport All")) { NPipelineUtils.InvalidateAndReimportAll(session.animation); } if (GUILayout.Button("Invalidate & Reimport All Deep")) { NPipelineUtils.InvalidateAndReimportAllDeep(session.animation); } if (GUILayout.Button("Help")) { NPVoxAnimHelpWindow.ShowWindow(); } EditorGUILayout.EndHorizontal(); GUILayout.Label("Preview: ", EditorStyles.boldLabel); DrawPreview(); if (!viewModel.IsPlaying) { GUILayout.Space(10); GUILayout.Label("Frames: ", EditorStyles.boldLabel); DrawFrameSelection(); GUILayout.Space(10); DrawModelSelection(); DrawTransformationSelector(); GUILayout.Space(10); GUILayout.Label("Presentation: ", EditorStyles.boldLabel); DrawModeToolbar(); DrawSocketTools(); } else { // Debug.Log("playing"); DrawFrameList(); } DrawMaterialSelection(); session.groundplateOffset = EditorGUILayout.FloatField("Ground Offset", session.groundplateOffset); EditorGUILayout.EndVertical(); if (meshRefreshRequested) { meshRefreshRequested = false; UpdateMeshes(); SceneView.RepaintAll(); } // unfocus by pressing escape Event e = Event.current; if (e.isKey && e.keyCode == KeyCode.Escape) { unfocus(); } // ground plate if (viewModel.SelectedFrame != null && viewModel.SelectedFrame.Source != null && session.groundFilter) { NPVoxModel model = viewModel.SelectedFrame.Source.GetProduct(); NPVoxToUnity n2u = new NPVoxToUnity(model, viewModel.Animation.MeshFactory.VoxelSize); Vector3 pos = n2u.ToUnityPosition(new Vector3(model.BoundingBox.SaveCenter.x, model.BoundingBox.SaveCenter.y, model.BoundingBox.Forward + 1)); session.groundFilter.transform.position = pos + Vector3.forward * session.groundplateOffset; } KeyboardShortcuts(); }