public void Setup() { #if UNITY_EDITOR SetupMonoScriptTypeNames(); #endif EditorVR.DefaultMenu = GetTypeSafe(m_DefaultMainMenuName); EditorVR.DefaultAlternateMenu = GetTypeSafe(m_DefaultAlternateMenuName); if (m_DefaultToolStackNames != null) { EditorVR.DefaultTools = m_DefaultToolStackNames.Select(GetTypeSafe).ToArray(); } if (m_HiddenTypeNames != null) { EditorVR.HiddenTypes = m_HiddenTypeNames.Select(GetTypeSafe).ToArray(); } s_Instance = m_Instance = ObjectUtils.CreateGameObjectWithComponent <EditorVR>(); if (Application.isPlaying) { var camera = CameraUtils.GetMainCamera(); var cameraRig = m_Instance.transform; VRView.CreateCameraRig(ref camera, ref cameraRig); } XRSettings.eyeTextureResolutionScale = m_RenderScale; }
public void Setup() { EditorVR.defaultTools = m_DefaultToolStack.Select(ms => ms.GetClass()).ToArray(); m_Instance = ObjectUtils.CreateGameObjectWithComponent <EditorVR>(); XRSettings.eyeTextureResolutionScale = m_RenderScale; }
void OnDestroy() { s_Instance = null; foreach (var nested in m_NestedModules.Values) { nested.OnDestroy(); } }
public void Dispose() { m_Instance.Shutdown(); // Give a chance for dependent systems (e.g. serialization) to shut-down before destroying if (m_Instance) { ObjectUtils.Destroy(m_Instance.gameObject); } s_Instance = m_Instance = null; }
void OnDestroy() { s_Instance = null; foreach (var nested in m_NestedModules.Values) { nested.OnDestroy(); } #if UNDO_PATCH DrivenRectTransformTracker.BlockUndo = false; #endif }
static void PreferencesGUI() { EditorGUILayout.BeginVertical(); // Show EditorXR GameObjects { const string title = "Show EditorXR GameObjects"; const string tooltip = "Normally, EditorXR GameObjects are hidden in the Hierarchy. Would you like to show them?"; EditorGUI.BeginChangeCheck(); EditorVR.showGameObjects = EditorGUILayout.Toggle(new GUIContent(title, tooltip), EditorVR.showGameObjects); if (EditorGUI.EndChangeCheck() && s_Instance) { s_Instance.SetHideFlags(EditorVR.defaultHideFlags); } } // Preserve Layout { const string title = "Preserve Layout"; const string tooltip = "Check this to preserve your layout and location in EditorXR"; EditorVR.preserveLayout = EditorGUILayout.Toggle(new GUIContent(title, tooltip), EditorVR.preserveLayout); } // Include in Builds { const string title = "Include in Player Builds"; const string tooltip = "Normally, EditorXR will override its assembly definitions to keep its assemblies out of Player builds. Check this if you would like to skip this step and include EditorXR in Player builds"; EditorVR.includeInBuilds = EditorGUILayout.Toggle(new GUIContent(title, tooltip), EditorVR.includeInBuilds); } if (GUILayout.Button("Reset to Defaults", GUILayout.Width(140))) { EditorVR.ResetPreferences(); } EditorGUILayout.EndVertical(); }
public void Setup() { EditorVR.defaultTools = m_DefaultToolStack.Select(ms => ms.GetClass()).ToArray(); m_Instance = ObjectUtils.CreateGameObjectWithComponent <EditorVR>(); }
void Awake() { s_Instance = this; // Used only by PreferencesGUI Nested.evr = this; // Set this once for the convenience of all nested classes m_DefaultTools = defaultTools; SetHideFlags(defaultHideFlags); ClearDeveloperConsoleIfNecessary(); 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); 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; 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); AddModule <SnappingModule>(); 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 => { 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 <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(); GetNestedModule <Rays>().CreateAllProxies(); // In case we have anything selected at start, set up manipulators, inspector, etc. EditorApplication.delayCall += OnSelectionChanged; }