void Awake() { ClearDeveloperConsoleIfNecessary(); UpdateProjectFolders(); UpdateHierarchyData(); VRView.viewerPivot.parent = transform; // Parent the camera pivot under EditorVR if (VRSettings.loadedDeviceName == "OpenVR") { // Steam's reference position should be at the feet and not at the head as we do with Oculus VRView.viewerPivot.localPosition = Vector3.zero; } var hmdOnlyLayerMask = 0; if (m_PreviewCameraPrefab) { var go = U.Object.Instantiate(m_PreviewCameraPrefab); m_CustomPreviewCamera = go.GetComponentInChildren <IPreviewCamera>(); if (m_CustomPreviewCamera != null) { VRView.customPreviewCamera = m_CustomPreviewCamera.previewCamera; m_CustomPreviewCamera.vrCamera = VRView.viewerCamera; hmdOnlyLayerMask = m_CustomPreviewCamera.hmdOnlyLayerMask; } } VRView.cullingMask = UnityEditor.Tools.visibleLayers | hmdOnlyLayerMask; InitializePlayerHandle(); CreateDefaultActionMapInputs(); CreateAllProxies(); CreateDeviceDataForInputDevices(); m_DragAndDropModule = U.Object.AddComponent <DragAndDropModule>(gameObject); CreateEventSystem(); m_PixelRaycastModule = U.Object.AddComponent <PixelRaycastModule>(gameObject); m_PixelRaycastModule.ignoreRoot = transform; m_HighlightModule = U.Object.AddComponent <HighlightModule>(gameObject); m_LockModule = U.Object.AddComponent <LockModule>(gameObject); m_LockModule.updateAlternateMenu = (rayOrigin, o) => SetAlternateMenuVisibility(rayOrigin, o != null); ConnectInterfaces(m_LockModule); m_SelectionModule = U.Object.AddComponent <SelectionModule>(gameObject); m_SelectionModule.selected += SetLastSelectionRayOrigin; // when a selection occurs in the selection tool, call show in the alternate menu, allowing it to show/hide itself. m_SelectionModule.getGroupRoot = GetGroupRoot; ConnectInterfaces(m_SelectionModule); m_AllTools = U.Object.GetImplementationsOfInterface(typeof(ITool)).ToList(); m_MainMenuTools = m_AllTools.Where(t => !IsPermanentTool(t)).ToList(); // Don't show tools that can't be selected/toggled m_AllWorkspaceTypes = U.Object.GetImplementationsOfInterface(typeof(IWorkspace)).ToList(); UnityBrandColorScheme.sessionGradient = UnityBrandColorScheme.GetRandomGradient(); }
public void SetupMenuFaces() { int position = 0; foreach (var faceNameToButtons in m_FaceButtons) { m_MenuFaces[position].SetFaceData(faceNameToButtons.Key, faceNameToButtons.Value, UnityBrandColorScheme.GetRandomGradient()); ++position; } }
internal void Initialize() { if (UpdateInputManager != null) { UpdateInputManager(); } #if UNITY_EDITOR DrivenRectTransformTracker.StopRecordingUndo(); if (!Application.isPlaying) { ClearDeveloperConsoleIfNecessary(); } #endif HandleInitialization(); UnityBrandColorScheme.sessionGradient = UnityBrandColorScheme.GetRandomCuratedLightGradient(); UnityBrandColorScheme.saturatedSessionGradient = UnityBrandColorScheme.GetRandomCuratedGradient(); var delayedInitializationModules = new List <IDelayedInitializationModule>(); foreach (var module in ModuleLoaderCore.instance.modules) { var delayedInitializationModule = module as IDelayedInitializationModule; if (delayedInitializationModule != null) { delayedInitializationModules.Add(delayedInitializationModule); } } delayedInitializationModules.Sort((a, b) => a.initializationOrder.CompareTo(b.initializationOrder)); foreach (var module in delayedInitializationModules) { module.Initialize(); } }
MainMenuFace CreateFace(string sectionName) { if (m_Faces.Count == k_FaceCount) { Debug.LogWarning("Main Menu does not support more than 4 faces"); return(null); } var faceTransform = this.InstantiateUI(m_MenuFacePrefab.gameObject).transform; faceTransform.name = sectionName; faceTransform.SetParent(m_MenuFaceContainers[m_Faces.Count]); faceTransform.localRotation = Quaternion.identity; faceTransform.localScale = Vector3.one; faceTransform.localPosition = Vector3.zero; var face = faceTransform.GetComponent <MainMenuFace>(); m_Faces[sectionName] = face; face.gradientPair = UnityBrandColorScheme.GetRandomGradient(); face.title = sectionName; return(face); }
void Initialize() { #if UNITY_EDITOR #if UNITY_2018_2_OR_NEWER DrivenRectTransformTracker.StopRecordingUndo(); #elif UNDO_PATCH DrivenRectTransformTracker.BlockUndo = true; #endif #endif Nested.evr = this; // Set this once for the convenience of all nested classes m_DefaultTools = DefaultTools; SetHideFlags(defaultHideFlags); #if UNITY_EDITOR if (!Application.isPlaying) { ClearDeveloperConsoleIfNecessary(); } #endif HandleInitialization(); m_Interfaces = (Interfaces)AddNestedModule(typeof(Interfaces)); AddModule <SerializedPreferencesModule>(); // Added here in case any nested modules have preference serialization AddNestedModule(typeof(SerializedPreferencesModuleConnector)); var nestedClassTypes = ObjectUtils.GetExtensionsOfClass(typeof(Nested)); foreach (var type in nestedClassTypes) { AddNestedModule(type); } LateBindNestedModules(nestedClassTypes); #if UNITY_EDITOR if (!Application.isPlaying) { AddModule <HierarchyModule>(); AddModule <ProjectFolderModule>(); } #endif AddModule <AdaptivePositionModule>(); var viewer = GetNestedModule <Viewer>(); viewer.preserveCameraRig = preserveLayout; viewer.InitializeCamera(); var deviceInputModule = AddModule <DeviceInputModule>(); deviceInputModule.InitializePlayerHandle(); deviceInputModule.CreateDefaultActionMapInputs(); deviceInputModule.processInput = ProcessInput; deviceInputModule.updatePlayerHandleMaps = Tools.UpdatePlayerHandleMaps; deviceInputModule.inputDeviceForRayOrigin = rayOrigin => (from deviceData in m_DeviceData where deviceData.rayOrigin == rayOrigin select deviceData.inputDevice).FirstOrDefault(); GetNestedModule <UI>().Initialize(); AddModule <KeyboardModule>(); var multipleRayInputModule = GetModule <MultipleRayInputModule>(); var dragAndDropModule = AddModule <DragAndDropModule>(); multipleRayInputModule.rayEntered += dragAndDropModule.OnRayEntered; multipleRayInputModule.rayExited += dragAndDropModule.OnRayExited; multipleRayInputModule.dragStarted += dragAndDropModule.OnDragStarted; multipleRayInputModule.dragEnded += dragAndDropModule.OnDragEnded; var tooltipModule = AddModule <TooltipModule>(); this.ConnectInterfaces(tooltipModule); multipleRayInputModule.rayEntered += tooltipModule.OnRayEntered; multipleRayInputModule.rayHovering += tooltipModule.OnRayHovering; multipleRayInputModule.rayExited += tooltipModule.OnRayExited; AddModule <ActionsModule>(); AddModule <HighlightModule>(); var lockModule = AddModule <LockModule>(); lockModule.updateAlternateMenu = (rayOrigin, o) => Menus.SetAlternateMenuVisibility(rayOrigin, o != null); AddModule <SelectionModule>(); var spatialHashModule = AddModule <SpatialHashModule>(); spatialHashModule.shouldExcludeObject = go => go.GetComponentInParent <EditorVR>(); spatialHashModule.Setup(); var intersectionModule = AddModule <IntersectionModule>(); this.ConnectInterfaces(intersectionModule); intersectionModule.Setup(spatialHashModule.spatialHash); // TODO: Support module dependencies via ConnectInterfaces GetNestedModule <Rays>().ignoreList = intersectionModule.standardIgnoreList; AddModule <SnappingModule>(); var vacuumables = GetNestedModule <Vacuumables>(); var miniWorlds = GetNestedModule <MiniWorlds>(); var workspaceModule = AddModule <WorkspaceModule>(); workspaceModule.preserveWorkspaces = preserveLayout; workspaceModule.HiddenTypes = HiddenTypes; workspaceModule.workspaceCreated += vacuumables.OnWorkspaceCreated; workspaceModule.workspaceCreated += miniWorlds.OnWorkspaceCreated; workspaceModule.workspaceCreated += workspace => { deviceInputModule.UpdatePlayerHandleMaps(); }; workspaceModule.workspaceDestroyed += vacuumables.OnWorkspaceDestroyed; workspaceModule.workspaceDestroyed += miniWorlds.OnWorkspaceDestroyed; UnityBrandColorScheme.sessionGradient = UnityBrandColorScheme.GetRandomCuratedLightGradient(); UnityBrandColorScheme.saturatedSessionGradient = UnityBrandColorScheme.GetRandomCuratedGradient(); var sceneObjectModule = AddModule <SceneObjectModule>(); sceneObjectModule.tryPlaceObject = (obj, targetScale) => { foreach (var miniWorld in miniWorlds.worlds) { if (!miniWorld.Contains(obj.position)) { continue; } var referenceTransform = miniWorld.referenceTransform; obj.transform.parent = null; obj.position = referenceTransform.position + Vector3.Scale(miniWorld.miniWorldTransform.InverseTransformPoint(obj.position), miniWorld.referenceTransform.localScale); obj.rotation = referenceTransform.rotation * Quaternion.Inverse(miniWorld.miniWorldTransform.rotation) * obj.rotation; obj.localScale = Vector3.Scale(Vector3.Scale(obj.localScale, referenceTransform.localScale), miniWorld.miniWorldTransform.lossyScale.Inverse()); spatialHashModule.AddObject(obj.gameObject); return(true); } return(false); }; AddModule <HapticsModule>(); AddModule <GazeDivergenceModule>(); AddModule <SpatialHintModule>(); AddModule <SpatialScrollModule>(); AddModule <FeedbackModule>(); AddModule <WebModule>(); //TODO: External module support (removes need for CCU in this instance) #if INCLUDE_POLY_TOOLKIT AddModule <PolyModule>(); #endif viewer.AddPlayerModel(); viewer.AddPlayerFloor(); GetNestedModule <Rays>().CreateAllProxies(); // In case we have anything selected at start, set up manipulators, inspector, etc. EditorApplication.delayCall += OnSelectionChanged; }
void Awake() { Nested.evr = this; // Set this once for the convenience of all nested classes m_DefaultTools = defaultTools; ClearDeveloperConsoleIfNecessary(); m_Interfaces = (Interfaces)AddNestedModule(typeof(Interfaces)); AddModule <SerializedPreferencesModule>(); // Added here in case any nested modules have preference serialization var nestedClassTypes = ObjectUtils.GetExtensionsOfClass(typeof(Nested)); foreach (var type in nestedClassTypes) { AddNestedModule(type); } LateBindNestedModules(nestedClassTypes); AddModule <HierarchyModule>(); AddModule <ProjectFolderModule>(); var viewer = GetNestedModule <Viewer>(); viewer.preserveCameraRig = preserveLayout; viewer.InitializeCamera(); var deviceInputModule = AddModule <DeviceInputModule>(); deviceInputModule.InitializePlayerHandle(); deviceInputModule.CreateDefaultActionMapInputs(); deviceInputModule.processInput = ProcessInput; deviceInputModule.updatePlayerHandleMaps = Tools.UpdatePlayerHandleMaps; GetNestedModule <UI>().Initialize(); AddModule <KeyboardModule>(); var multipleRayInputModule = GetModule <MultipleRayInputModule>(); var dragAndDropModule = AddModule <DragAndDropModule>(); multipleRayInputModule.rayEntered += dragAndDropModule.OnRayEntered; multipleRayInputModule.rayExited += dragAndDropModule.OnRayExited; multipleRayInputModule.dragStarted += dragAndDropModule.OnDragStarted; multipleRayInputModule.dragEnded += dragAndDropModule.OnDragEnded; var tooltipModule = AddModule <TooltipModule>(); m_Interfaces.ConnectInterfaces(tooltipModule); multipleRayInputModule.rayEntered += tooltipModule.OnRayEntered; multipleRayInputModule.rayExited += tooltipModule.OnRayExited; AddModule <ActionsModule>(); AddModule <HighlightModule>(); var lockModule = AddModule <LockModule>(); lockModule.updateAlternateMenu = (rayOrigin, o) => Menus.SetAlternateMenuVisibility(rayOrigin, o != null); AddModule <SelectionModule>(); var spatialHashModule = AddModule <SpatialHashModule>(); spatialHashModule.shouldExcludeObject = go => go.GetComponentInParent <EditorVR>(); spatialHashModule.Setup(); var intersectionModule = AddModule <IntersectionModule>(); m_Interfaces.ConnectInterfaces(intersectionModule); intersectionModule.Setup(spatialHashModule.spatialHash); var snappingModule = AddModule <SnappingModule>(); snappingModule.raycast = intersectionModule.Raycast; var vacuumables = GetNestedModule <Vacuumables>(); var miniWorlds = GetNestedModule <MiniWorlds>(); var workspaceModule = AddModule <WorkspaceModule>(); workspaceModule.preserveWorkspaces = preserveLayout; workspaceModule.workspaceCreated += vacuumables.OnWorkspaceCreated; workspaceModule.workspaceCreated += miniWorlds.OnWorkspaceCreated; workspaceModule.workspaceCreated += workspace => { workspaceModule.workspaceInputs.Add((WorkspaceInput)deviceInputModule.CreateActionMapInputForObject(workspace, null)); deviceInputModule.UpdatePlayerHandleMaps(); }; workspaceModule.workspaceDestroyed += vacuumables.OnWorkspaceDestroyed; workspaceModule.workspaceDestroyed += miniWorlds.OnWorkspaceDestroyed; UnityBrandColorScheme.sessionGradient = UnityBrandColorScheme.GetRandomGradient(); var sceneObjectModule = AddModule <SceneObjectModule>(); sceneObjectModule.tryPlaceObject = (obj, targetScale) => { foreach (var miniWorld in miniWorlds.worlds) { if (!miniWorld.Contains(obj.position)) { continue; } var referenceTransform = miniWorld.referenceTransform; obj.transform.parent = null; obj.position = referenceTransform.position + Vector3.Scale(miniWorld.miniWorldTransform.InverseTransformPoint(obj.position), miniWorld.referenceTransform.localScale); obj.rotation = referenceTransform.rotation * Quaternion.Inverse(miniWorld.miniWorldTransform.rotation) * obj.rotation; obj.localScale = Vector3.Scale(Vector3.Scale(obj.localScale, referenceTransform.localScale), miniWorld.miniWorldTransform.lossyScale); spatialHashModule.AddObject(obj.gameObject); return(true); } return(false); }; viewer.AddPlayerModel(); GetNestedModule <Rays>().CreateAllProxies(); // In case we have anything selected at start, set up manipulators, inspector, etc. EditorApplication.delayCall += OnSelectionChanged; }
void Awake() { Nested.evr = this; // Set this once for the convenience of all nested classes ClearDeveloperConsoleIfNecessary(); m_DirectSelection = new DirectSelection(); m_Interfaces = new Interfaces(); m_Menus = new Menus(); m_MiniWorlds = new MiniWorlds(); m_Rays = new Rays(); m_Tools = new Tools(); m_UI = new UI(); m_Viewer = new Viewer(); m_Vacuumables = new Vacuumables(); m_HierarchyModule = AddModule <HierarchyModule>(); m_ProjectFolderModule = AddModule <ProjectFolderModule>(); VRView.cameraRig.parent = transform; // Parent the camera rig under EditorVR VRView.cameraRig.hideFlags = defaultHideFlags; if (VRSettings.loadedDeviceName == "OpenVR") { // Steam's reference position should be at the feet and not at the head as we do with Oculus VRView.cameraRig.localPosition = Vector3.zero; } var hmdOnlyLayerMask = 0; if (m_PreviewCameraPrefab) { var go = ObjectUtils.Instantiate(m_PreviewCameraPrefab); m_CustomPreviewCamera = go.GetComponentInChildren <IPreviewCamera>(); if (m_CustomPreviewCamera != null) { VRView.customPreviewCamera = m_CustomPreviewCamera.previewCamera; m_CustomPreviewCamera.vrCamera = VRView.viewerCamera; hmdOnlyLayerMask = m_CustomPreviewCamera.hmdOnlyLayerMask; m_Interfaces.ConnectInterfaces(m_CustomPreviewCamera); } } VRView.cullingMask = UnityEditor.Tools.visibleLayers | hmdOnlyLayerMask; m_DeviceInputModule = AddModule <DeviceInputModule>(); m_DeviceInputModule.InitializePlayerHandle(); m_DeviceInputModule.CreateDefaultActionMapInputs(); m_DeviceInputModule.processInput = ProcessInput; m_DeviceInputModule.updatePlayerHandleMaps = m_Tools.UpdatePlayerHandleMaps; m_UI.Initialize(); m_KeyboardModule = AddModule <KeyboardModule>(); m_DragAndDropModule = AddModule <DragAndDropModule>(); m_InputModule.rayEntered += m_DragAndDropModule.OnRayEntered; m_InputModule.rayExited += m_DragAndDropModule.OnRayExited; m_InputModule.dragStarted += m_DragAndDropModule.OnDragStarted; m_InputModule.dragEnded += m_DragAndDropModule.OnDragEnded; m_TooltipModule = AddModule <TooltipModule>(); m_Interfaces.ConnectInterfaces(m_TooltipModule); m_InputModule.rayEntered += m_TooltipModule.OnRayEntered; m_InputModule.rayExited += m_TooltipModule.OnRayExited; m_PixelRaycastModule = AddModule <PixelRaycastModule>(); m_PixelRaycastModule.ignoreRoot = transform; m_PixelRaycastModule.raycastCamera = m_UI.eventCamera; m_HighlightModule = AddModule <HighlightModule>(); m_ActionsModule = AddModule <ActionsModule>(); m_LockModule = AddModule <LockModule>(); m_LockModule.updateAlternateMenu = (rayOrigin, o) => m_Menus.SetAlternateMenuVisibility(rayOrigin, o != null); m_SelectionModule = AddModule <SelectionModule>(); m_SelectionModule.selected += m_Rays.SetLastSelectionRayOrigin; // when a selection occurs in the selection tool, call show in the alternate menu, allowing it to show/hide itself. m_SelectionModule.getGroupRoot = GetGroupRoot; m_SpatialHashModule = AddModule <SpatialHashModule>(); m_SpatialHashModule.shouldExcludeObject = go => go.GetComponentInParent <EditorVR>(); m_SpatialHashModule.Setup(); m_IntersectionModule = AddModule <IntersectionModule>(); m_Interfaces.ConnectInterfaces(m_IntersectionModule); m_IntersectionModule.Setup(m_SpatialHashModule.spatialHash); m_Menus.mainMenuTools = m_Tools.allTools.Where(t => !m_Tools.IsPermanentTool(t)).ToList(); // Don't show tools that can't be selected/toggled m_WorkspaceModule = AddModule <WorkspaceModule>(); m_WorkspaceModule.workspaceCreated += m_Vacuumables.OnWorkspaceCreated; m_WorkspaceModule.workspaceCreated += m_MiniWorlds.OnWorkspaceCreated; m_WorkspaceModule.workspaceCreated += (workspace) => { m_DeviceInputModule.UpdatePlayerHandleMaps(); }; m_WorkspaceModule.workspaceDestroyed += m_Vacuumables.OnWorkspaceDestroyed; m_WorkspaceModule.workspaceDestroyed += (workspace) => { m_Interfaces.DisconnectInterfaces(workspace); }; m_WorkspaceModule.workspaceDestroyed += m_MiniWorlds.OnWorkspaceDestroyed; UnityBrandColorScheme.sessionGradient = UnityBrandColorScheme.GetRandomGradient(); m_SceneObjectModule = AddModule <SceneObjectModule>(); m_SceneObjectModule.shouldPlaceObject = (obj, targetScale) => { foreach (var miniWorld in m_MiniWorlds.worlds) { if (!miniWorld.Contains(obj.position)) { continue; } var referenceTransform = miniWorld.referenceTransform; obj.transform.parent = null; obj.position = referenceTransform.position + Vector3.Scale(miniWorld.miniWorldTransform.InverseTransformPoint(obj.position), miniWorld.referenceTransform.localScale); obj.rotation = referenceTransform.rotation * Quaternion.Inverse(miniWorld.miniWorldTransform.rotation) * obj.rotation; obj.localScale = Vector3.Scale(Vector3.Scale(obj.localScale, referenceTransform.localScale), miniWorld.miniWorldTransform.lossyScale); return(false); } return(true); }; m_Viewer.AddPlayerModel(); m_Rays.CreateAllProxies(); // In case we have anything selected at start, set up manipulators, inspector, etc. EditorApplication.delayCall += OnSelectionChanged; }