private void Awake() { subsystemManager = GetComponentInParent <SubsystemManager>(); }
static void OnReloadSubsystemsComplete() { SubsystemManager.GetSubsystemDescriptors(displayDescriptors); }
// Start is called before the first frame update void Start() { var activeLoader = LoaderUtility.GetActiveLoader(); var planeDescriptors = new List <XRPlaneSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRPlaneSubsystemDescriptor>(planeDescriptors); var rayCastDescriptors = new List <XRRaycastSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRRaycastSubsystemDescriptor>(rayCastDescriptors); var faceDescriptors = new List <XRFaceSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRFaceSubsystemDescriptor>(faceDescriptors); var imageDescriptors = new List <XRImageTrackingSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRImageTrackingSubsystemDescriptor>(imageDescriptors); var envDescriptors = new List <XREnvironmentProbeSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XREnvironmentProbeSubsystemDescriptor>(envDescriptors); var anchorDescriptors = new List <XRAnchorSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRAnchorSubsystemDescriptor>(anchorDescriptors); var objectDescriptors = new List <XRObjectTrackingSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRObjectTrackingSubsystemDescriptor>(objectDescriptors); var participantDescriptors = new List <XRParticipantSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRParticipantSubsystemDescriptor>(participantDescriptors); var depthDescriptors = new List <XRDepthSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRDepthSubsystemDescriptor>(depthDescriptors); var occlusionDescriptors = new List <XROcclusionSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XROcclusionSubsystemDescriptor>(occlusionDescriptors); var cameraDescriptors = new List <XRCameraSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRCameraSubsystemDescriptor>(cameraDescriptors); var sessionDescriptors = new List <XRSessionSubsystemDescriptor>(); SubsystemManager.GetSubsystemDescriptors <XRSessionSubsystemDescriptor>(sessionDescriptors); if (planeDescriptors.Count > 0 && rayCastDescriptors.Count > 0) { m_SimpleAR.interactable = true; m_Scale.interactable = true; m_Interaction.interactable = true; m_SampleUX.interactable = true; m_CheckSupport.interactable = true; } if (faceDescriptors.Count > 0) { m_FaceTracking.interactable = true; #if UNITY_IOS m_FaceBlendShapes.interactable = true; #endif #if UNITY_ANDROID m_FaceRegions.interactable = true; #endif foreach (var faceDescriptor in faceDescriptors) { if (faceDescriptor.supportsEyeTracking) { m_EyePoses.interactable = true; m_FixationPoint.interactable = true; m_EyeLasers.interactable = true; break; } } } if (occlusionDescriptors.Count > 0) { foreach (var occlusionDescriptor in occlusionDescriptors) { if (occlusionDescriptor.supportsHumanSegmentationDepthImage && occlusionDescriptor.supportsHumanSegmentationStencilImage) { m_HumanSegmentation.interactable = true; break; } } } if (cameraDescriptors.Count > 0) { foreach (var cameraDescriptor in cameraDescriptors) { if ((cameraDescriptor.supportsAverageBrightness || cameraDescriptor.supportsAverageIntensityInLumens) && cameraDescriptor.supportsAverageColorTemperature && cameraDescriptor.supportsCameraConfigurations && cameraDescriptor.supportsCameraImage) { m_LightEstimation.interactable = true; } } } if (imageDescriptors.Count > 0) { m_ImageTracking.interactable = true; } if (envDescriptors.Count > 0) { m_EnvironmentProbes.interactable = true; } if (planeDescriptors.Count > 0) { m_PlaneDetection.interactable = true; foreach (var planeDescriptor in planeDescriptors) { if (planeDescriptor.supportsClassification) { m_PlaneClassification.interactable = true; break; } } } if (anchorDescriptors.Count > 0) { m_Anchors.interactable = true; } if (objectDescriptors.Count > 0) { m_ObjectTracking.interactable = true; } if (cameraDescriptors.Count > 0) { foreach (var cameraDescriptor in cameraDescriptors) { if (cameraDescriptor.supportsCameraImage) { m_CpuImages.interactable = true; break; } } } #if UNITY_IOS if (sessionDescriptors.Count > 0 && ARKitSessionSubsystem.worldMapSupported) { m_ARWorldMap.interactable = true; } if (planeDescriptors.Count > 0 && rayCastDescriptors.Count > 0 && participantDescriptors.Count > 0 && ARKitSessionSubsystem.supportsCollaboration) { m_ARCollaborationData.interactable = true; } if (sessionDescriptors.Count > 0 && ARKitSessionSubsystem.coachingOverlaySupported) { m_ARKitCoachingOverlay.interactable = true; } #endif if (depthDescriptors.Count > 0) { m_PointCloud.interactable = true; } if (planeDescriptors.Count > 0) { m_PlaneOcclusion.interactable = true; } if (activeLoader.GetLoadedSubsystem <XRMeshSubsystem>() != null) { m_Meshing.interactable = true; } }
/// <inheritdoc/> public void OnRemove(PSModuleInfo psModuleInfo) { SubsystemManager.UnregisterSubsystem <ICommandPredictor>(AzPredictor.Identifier); }
protected void VRDeviceFetch() { vrDisplays.Clear(); SubsystemManager.GetInstances(vrDisplays); }
private void DoToolbarGUI() { if (Event.current.isKey || Event.current.type == EventType.Used) { return; } GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes(); GUILayout.BeginHorizontal(EditorStyles.toolbar); { var availableTypes = GetAvailableWindowTypes(); if (availableTypes.Count > 1) { var typeNames = availableTypes.Values.ToList(); var types = availableTypes.Keys.ToList(); int viewIndex = EditorGUILayout.Popup(typeNames.IndexOf(titleContent.text), typeNames.ToArray(), EditorStyles.toolbarPopup, GUILayout.Width(90)); EditorGUILayout.Space(); if (types[viewIndex] != typeof(GameView)) { SwapMainWindow(types[viewIndex]); } } if (ModuleManager.ShouldShowMultiDisplayOption()) { int display = EditorGUILayout.Popup(targetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopupLeft, GUILayout.Width(80)); if (display != targetDisplay) { targetDisplay = display; UpdateZoomAreaAndParent(); } } EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f)); DoZoomSlider(); // If the previous platform and current does not match, update the scale if ((int)currentSizeGroupType != prevSizeGroupType) { UpdateZoomAreaAndParent(); // Update the platform to the recent one prevSizeGroupType = (int)currentSizeGroupType; } if (FrameDebuggerUtility.IsLocalEnabled()) { GUILayout.FlexibleSpace(); Color oldCol = GUI.color; // This has nothing to do with animation recording. Can we replace this color with something else? GUI.color *= AnimationMode.recordedPropertyColor; GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.toolbarLabel); GUI.color = oldCol; // Make frame debugger windows repaint after each time game view repaints. // We want them to always display the latest & greatest game view // rendering state. if (Event.current.type == EventType.Repaint) { FrameDebuggerWindow.RepaintAll(); } } GUILayout.FlexibleSpace(); if (ShouldShowMetalFrameCaptureGUI()) { if (GUILayout.Button(Styles.metalFrameCaptureContent, EditorStyles.toolbarButton)) { m_Parent.CaptureMetalScene(); } } if (RenderDoc.IsLoaded()) { using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported())) { if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton)) { m_Parent.CaptureRenderDocScene(); GUIUtility.ExitGUI(); } } } SubsystemManager.GetSubsystemDescriptors <XRDisplaySubsystemDescriptor>(m_DisplaySubsystemDescs); // Allow the user to select how the XR device will be rendered during "Play In Editor" if (PlayerSettings.virtualRealitySupported || m_DisplaySubsystemDescs.Count != 0) { EditorGUI.BeginChangeCheck(); GameViewRenderMode currentGameViewRenderMode = UnityEngine.XR.XRSettings.gameViewRenderMode; int selectedRenderMode = EditorGUILayout.Popup(Mathf.Clamp(((int)currentGameViewRenderMode) - 1, 0, Styles.xrRenderingModes.Length - 1), Styles.xrRenderingModes, EditorStyles.toolbarPopup, GUILayout.Width(80)); if (EditorGUI.EndChangeCheck() && currentGameViewRenderMode != GameViewRenderMode.None) { SetXRRenderMode(selectedRenderMode); } } maximizeOnPlay = GUILayout.Toggle(maximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton); EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton); m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton); if (EditorGUILayout.DropDownToggle(ref m_Gizmos, Styles.gizmosContent, EditorStyles.toolbarDropDownToggleRight)) { Rect rect = GUILayoutUtility.topLevel.GetLast(); if (AnnotationWindow.ShowAtPosition(rect, true)) { GUIUtility.ExitGUI(); } } } GUILayout.EndHorizontal(); }
private void Awake() { metaTileMap = GetComponentInChildren <MetaTileMap>(); subsystemManager = GetComponent <SubsystemManager>(); interactableTiles = GetComponent <InteractableTiles>(); }
private void Awake() { subsystemManager = GetComponentInParent <SubsystemManager>(); reactionManager = GetComponentInParent <ReactionManager>(); matrix = GetComponent <Matrix>(); }
public IEnumerator Run(GraphicsTestCase testCase) { SceneManager.LoadScene(testCase.ScenePath); // Always wait one frame for scene load yield return(null); var cameras = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>()); var settings = Object.FindObjectOfType <LWGraphicsTestSettings>(); Assert.IsNotNull(settings, "Invalid test scene, couldn't find LWGraphicsTestSettings"); // Stereo screen capture on Mac generates monoscopic images and won't be fixed. Assume.That((Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.OSXPlayer), "Stereo tests do not run on MacOSX."); var referenceImage = testCase.ReferenceImage; // make sure we're rendering in the same size as the reference image, otherwise this is not really comparable. Screen.SetResolution(referenceImage.width, referenceImage.height, FullScreenMode.Windowed); #if UNITY_2020_2_OR_NEWER // Ensure a valid XR display is active List <XRDisplaySubsystem> xrDisplays = new List <XRDisplaySubsystem>(); SubsystemManager.GetInstances(xrDisplays); Assume.That(xrDisplays.Count > 0 && xrDisplays[0].running, "No XR display active!"); // Set mirror view to side-by-side (both eyes) xrDisplays[0].SetPreferredMirrorBlitMode(XRMirrorViewBlitMode.SideBySide); #else XRSettings.gameViewRenderMode = GameViewRenderMode.BothEyes; #endif yield return(null); foreach (var camera in cameras) { camera.stereoTargetEye = StereoTargetEyeMask.Both; } var tempScreenshotFile = Path.ChangeExtension(Path.GetTempFileName(), ".png"); // clean up previous file if it happens to exist at this point if (FileAvailable(tempScreenshotFile)) { System.IO.File.Delete(tempScreenshotFile); } for (int i = 0; i < settings.WaitFrames; i++) { yield return(null); } // wait for rendering to complete yield return(new WaitForEndOfFrame()); // we'll take a screenshot here, as what we want to compare is the actual result on-screen. // ScreenCapture.CaptureScreenshotAsTexture --> does not work since colorspace is wrong, would need colorspace change and thus color compression // ScreenCapture.CaptureScreenshotIntoRenderTexture --> does not work since texture is flipped, would need another pass // so we need to capture and reload the resulting file. ScreenCapture.CaptureScreenshot(tempScreenshotFile, ScreenCapture.StereoScreenCaptureMode.BothEyes); // NOTE: there's discussions around whether Unity has actually documented this correctly. // Unity says: next frame MUST have the file ready // Community says: not true, file write might take longer, so have to explicitly check the file handle before use // https://forum.unity.com/threads/how-to-wait-for-capturescreen-to-complete.172194/ yield return(null); while (!FileAvailable(tempScreenshotFile)) { yield return(null); } // load the screenshot back into memory and change to the same format as we want to compare with var actualImage = new Texture2D(1, 1); actualImage.LoadImage(System.IO.File.ReadAllBytes(tempScreenshotFile)); if (actualImage.width != referenceImage.width || actualImage.height != referenceImage.height) { Debug.LogWarning("[" + testCase.ScenePath + "] Image size differs (ref: " + referenceImage.width + "x" + referenceImage.height + " vs. actual: " + actualImage.width + "x" + actualImage.height + "). " + (Application.isEditor ? " is your GameView set to a different resolution than the reference images?" : "is your build size different than the reference images?")); actualImage = ChangeTextureSize(actualImage, referenceImage.width, referenceImage.height); } // ref is usually in RGB24 or RGBA32 while actual is in ARGB32, we need to convert formats if (referenceImage.format != actualImage.format) { actualImage = ChangeTextureFormat(actualImage, referenceImage.format); } // delete temporary file File.Delete(tempScreenshotFile); // for testing // File.WriteAllBytes("reference.png", referenceImage.EncodeToPNG()); // File.WriteAllBytes("actual.png", actualImage.EncodeToPNG()); ImageAssert.AreEqual(referenceImage, actualImage, settings.ImageComparisonSettings); }
static XRRaycastSubsystem CreateTestRaycastSubsystem() { SubsystemManager.GetSubsystemDescriptors(s_Descs); return(s_Descs[0].Create()); }
/// <inheritdoc/> public void OnImport() { var predictor = new AzPredictor(); SubsystemManager.RegisterSubsystem <ICommandPredictor, AzPredictor>(predictor); }
public static void RegisterSubsystem() { try { Assert.Throws <ArgumentNullException>( paramName: "proxy", () => SubsystemManager.RegisterSubsystem <ICommandPredictor, MyPredictor>(null)); Assert.Throws <ArgumentNullException>( paramName: "proxy", () => SubsystemManager.RegisterSubsystem(SubsystemKind.CommandPredictor, null)); Assert.Throws <ArgumentException>( paramName: "proxy", () => SubsystemManager.RegisterSubsystem((SubsystemKind)0, predictor1)); // Register 'predictor1' SubsystemManager.RegisterSubsystem <ICommandPredictor, MyPredictor>(predictor1); // Now validate the SubsystemInfo of the 'ICommandPredictor' subsystem SubsystemInfo ssInfo = SubsystemManager.GetSubsystemInfo(typeof(ICommandPredictor)); SubsystemInfo crossPlatformDscInfo = SubsystemManager.GetSubsystemInfo(typeof(ICrossPlatformDsc)); VerifyCommandPredictorMetadata(ssInfo); Assert.True(ssInfo.IsRegistered); Assert.Single(ssInfo.Implementations); // Now validate the 'ImplementationInfo' var implInfo = ssInfo.Implementations[0]; Assert.Equal(predictor1.Id, implInfo.Id); Assert.Equal(predictor1.Name, implInfo.Name); Assert.Equal(predictor1.Description, implInfo.Description); Assert.Equal(SubsystemKind.CommandPredictor, implInfo.Kind); Assert.Same(typeof(MyPredictor), implInfo.ImplementationType); // Now validate the subsystem implementation itself. ICommandPredictor impl = SubsystemManager.GetSubsystem <ICommandPredictor>(); Assert.Same(impl, predictor1); Assert.Null(impl.FunctionsToDefine); Assert.Equal(SubsystemKind.CommandPredictor, impl.Kind); const string Client = "SubsystemTest"; const string Input = "Hello world"; var predClient = new PredictionClient(Client, PredictionClientKind.Terminal); var predCxt = PredictionContext.Create(Input); var results = impl.GetSuggestion(predClient, predCxt, CancellationToken.None); Assert.Equal($"'{Input}' from '{Client}' - TEST-1 from {impl.Name}", results.SuggestionEntries[0].SuggestionText); Assert.Equal($"'{Input}' from '{Client}' - TeSt-2 from {impl.Name}", results.SuggestionEntries[1].SuggestionText); // Now validate the all-subsystem-implementation collection. ReadOnlyCollection <ICommandPredictor> impls = SubsystemManager.GetSubsystems <ICommandPredictor>(); Assert.Single(impls); Assert.Same(predictor1, impls[0]); // Register 'predictor2' SubsystemManager.RegisterSubsystem(SubsystemKind.CommandPredictor, predictor2); // Now validate the SubsystemInfo of the 'ICommandPredictor' subsystem VerifyCommandPredictorMetadata(ssInfo); Assert.True(ssInfo.IsRegistered); Assert.Equal(2, ssInfo.Implementations.Count); // Now validate the new 'ImplementationInfo' implInfo = ssInfo.Implementations[1]; Assert.Equal(predictor2.Id, implInfo.Id); Assert.Equal(predictor2.Name, implInfo.Name); Assert.Equal(predictor2.Description, implInfo.Description); Assert.Equal(SubsystemKind.CommandPredictor, implInfo.Kind); Assert.Same(typeof(MyPredictor), implInfo.ImplementationType); // Now validate the new subsystem implementation. impl = SubsystemManager.GetSubsystem <ICommandPredictor>(); Assert.Same(impl, predictor2); // Now validate the all-subsystem-implementation collection. impls = SubsystemManager.GetSubsystems <ICommandPredictor>(); Assert.Equal(2, impls.Count); Assert.Same(predictor1, impls[0]); Assert.Same(predictor2, impls[1]); } finally { SubsystemManager.UnregisterSubsystem <ICommandPredictor>(predictor1.Id); SubsystemManager.UnregisterSubsystem(SubsystemKind.CommandPredictor, predictor2.Id); } }
static XRCameraSubsystem CreateTestCameraSubsystem() { SubsystemManager.GetSubsystemDescriptors(s_Descs); return(s_Descs[0].Create()); }
public void Awake() { tilemap = GetComponent <Tilemap>(); subsystemManager = GetComponentInParent <SubsystemManager>(); }
static XRAnchorSubsystem CreateTestAnchorSubsystem() { SubsystemManager.GetSubsystemDescriptors(s_Descs); return(s_Descs[0].Create()); }
static public void SaveSubsystemAsset(this Subsystem item) { item.SaveNewAsset(item.GetSubsystemAssetPath()); SubsystemManager.GetInstance().Refresh(); }