Ejemplo n.º 1
0
    public static OVRRuntimeSettings GetRuntimeSettings()
    {
        OVRRuntimeSettings settings = null;

#if UNITY_EDITOR
        string oculusRuntimeSettingsAssetPath = GetOculusRuntimeSettingsAssetPath();
        try
        {
            settings = AssetDatabase.LoadAssetAtPath(oculusRuntimeSettingsAssetPath, typeof(OVRRuntimeSettings)) as OVRRuntimeSettings;
        }
        catch (System.Exception e)
        {
            Debug.LogWarningFormat("Unable to load RuntimeSettings from {0}, error {1}", oculusRuntimeSettingsAssetPath, e.Message);
        }

        if (settings == null && !BuildPipeline.isBuildingPlayer)
        {
            settings = ScriptableObject.CreateInstance <OVRRuntimeSettings>();

            AssetDatabase.CreateAsset(settings, oculusRuntimeSettingsAssetPath);
        }
#else
        settings = Resources.Load <OVRRuntimeSettings>("OculusRuntimeSettings");
        if (settings == null)
        {
            Debug.LogWarning("Failed to load runtime settings. Using default runtime settings instead.");
            settings = ScriptableObject.CreateInstance <OVRRuntimeSettings>();
        }
#endif
        return(settings);
    }
Ejemplo n.º 2
0
    public static void CommitRuntimeSettings(OVRRuntimeSettings runtimeSettings)
    {
        string runtimeSettingsAssetPath = GetOculusRuntimeSettingsAssetPath();

        if (AssetDatabase.GetAssetPath(runtimeSettings) != runtimeSettingsAssetPath)
        {
            Debug.LogWarningFormat("The asset path of RuntimeSettings is wrong. Expect {0}, get {1}", runtimeSettingsAssetPath, AssetDatabase.GetAssetPath(runtimeSettings));
        }
        EditorUtility.SetDirty(runtimeSettings);
    }
Ejemplo n.º 3
0
    override public void OnInspectorGUI()
    {
        OVRRuntimeSettings runtimeSettings = OVRRuntimeSettings.GetRuntimeSettings();

#if UNITY_ANDROID
        OVRProjectConfig projectConfig = OVRProjectConfig.GetProjectConfig();
        OVRProjectConfigEditor.DrawTargetDeviceInspector(projectConfig);

        EditorGUILayout.Space();
#endif

        DrawDefaultInspector();

        bool modified = false;

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_ANDROID
        OVRManager manager = (OVRManager)target;

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Display", EditorStyles.boldLabel);

        OVRManager.ColorSpace colorGamut = runtimeSettings.colorSpace;
        OVREditorUtil.SetupEnumField(target, new GUIContent("Color Gamut",
                                                            "The target color gamut when displayed on the HMD"), ref colorGamut, ref modified,
                                     "https://developer.oculus.com/documentation/unity/unity-color-space/");
        manager.colorGamut = colorGamut;

        if (modified)
        {
            runtimeSettings.colorSpace = colorGamut;
            OVRRuntimeSettings.CommitRuntimeSettings(runtimeSettings);
        }
#endif

#if UNITY_ANDROID
        EditorGUILayout.Space();
        OVRProjectConfigEditor.DrawProjectConfigInspector(projectConfig);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Mixed Reality Capture for Quest", EditorStyles.boldLabel);
        EditorGUI.indentLevel++;
        OVREditorUtil.SetupEnumField(target, "ActivationMode", ref manager.mrcActivationMode, ref modified);
        EditorGUI.indentLevel--;
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        manager.expandMixedRealityCapturePropertySheet = EditorGUILayout.BeginFoldoutHeaderGroup(manager.expandMixedRealityCapturePropertySheet, "Mixed Reality Capture");
        OVREditorUtil.DisplayDocLink("https://developer.oculus.com/documentation/unity/unity-mrc/");
        EditorGUILayout.EndHorizontal();
        if (manager.expandMixedRealityCapturePropertySheet)
        {
            string[] layerMaskOptions = new string[32];
            for (int i = 0; i < 32; ++i)
            {
                layerMaskOptions[i] = LayerMask.LayerToName(i);
                if (layerMaskOptions[i].Length == 0)
                {
                    layerMaskOptions[i] = "<Layer " + i.ToString() + ">";
                }
            }

            EditorGUI.indentLevel++;

            OVREditorUtil.SetupBoolField(target, "enableMixedReality", ref manager.enableMixedReality, ref modified);
            OVREditorUtil.SetupEnumField(target, "compositionMethod", ref manager.compositionMethod, ref modified);
            OVREditorUtil.SetupLayerMaskField(target, "extraHiddenLayers", ref manager.extraHiddenLayers, layerMaskOptions, ref modified);
            OVREditorUtil.SetupLayerMaskField(target, "extraVisibleLayers", ref manager.extraVisibleLayers, layerMaskOptions, ref modified);
            OVREditorUtil.SetupBoolField(target, "dynamicCullingMask", ref manager.dynamicCullingMask, ref modified);

            if (manager.compositionMethod == OVRManager.CompositionMethod.External)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("External Composition", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;

                OVREditorUtil.SetupColorField(target, "backdropColor (target, Rift)", ref manager.externalCompositionBackdropColorRift, ref modified);
                OVREditorUtil.SetupColorField(target, "backdropColor (target, Quest)", ref manager.externalCompositionBackdropColorQuest, ref modified);
                EditorGUI.indentLevel--;
            }

            if (manager.compositionMethod == OVRManager.CompositionMethod.Direct)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Direct Composition", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
                OVREditorUtil.SetupEnumField(target, "capturingCameraDevice", ref manager.capturingCameraDevice, ref modified);
                OVREditorUtil.SetupBoolField(target, "flipCameraFrameHorizontally", ref manager.flipCameraFrameHorizontally, ref modified);
                OVREditorUtil.SetupBoolField(target, "flipCameraFrameVertically", ref manager.flipCameraFrameVertically, ref modified);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Chroma Key", EditorStyles.boldLabel);
                OVREditorUtil.SetupColorField(target, "chromaKeyColor", ref manager.chromaKeyColor, ref modified);
                OVREditorUtil.SetupFloatField(target, "chromaKeySimilarity", ref manager.chromaKeySimilarity, ref modified);
                OVREditorUtil.SetupFloatField(target, "chromaKeySmoothRange", ref manager.chromaKeySmoothRange, ref modified);
                OVREditorUtil.SetupFloatField(target, "chromaKeySpillRange", ref manager.chromaKeySpillRange, ref modified);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Dynamic Lighting", EditorStyles.boldLabel);
                OVREditorUtil.SetupBoolField(target, "useDynamicLighting", ref manager.useDynamicLighting, ref modified);
                OVREditorUtil.SetupEnumField(target, "depthQuality", ref manager.depthQuality, ref modified);
                OVREditorUtil.SetupFloatField(target, "dynamicLightingSmoothFactor", ref manager.dynamicLightingSmoothFactor, ref modified);
                OVREditorUtil.SetupFloatField(target, "dynamicLightingDepthVariationClampingValue", ref manager.dynamicLightingDepthVariationClampingValue, ref modified);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Virtual Green Screen", EditorStyles.boldLabel);
                OVREditorUtil.SetupEnumField(target, "virtualGreenScreenType", ref manager.virtualGreenScreenType, ref modified);
                OVREditorUtil.SetupFloatField(target, "virtualGreenScreenTopY", ref manager.virtualGreenScreenTopY, ref modified);
                OVREditorUtil.SetupFloatField(target, "virtualGreenScreenBottomY", ref manager.virtualGreenScreenBottomY, ref modified);
                OVREditorUtil.SetupBoolField(target, "virtualGreenScreenApplyDepthCulling", ref manager.virtualGreenScreenApplyDepthCulling, ref modified);
                OVREditorUtil.SetupFloatField(target, "virtualGreenScreenDepthTolerance", ref manager.virtualGreenScreenDepthTolerance, ref modified);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Latency Control", EditorStyles.boldLabel);
                OVREditorUtil.SetupFloatField(target, "handPoseStateLatency", ref manager.handPoseStateLatency, ref modified);
                EditorGUI.indentLevel--;
            }

            EditorGUI.indentLevel--;
        }
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_ANDROID
        // Insight Passthrough section
#if UNITY_ANDROID
        bool passthroughCapabilityEnabled = projectConfig.insightPassthroughEnabled;
        EditorGUI.BeginDisabledGroup(!passthroughCapabilityEnabled);
        GUIContent enablePassthroughContent = new GUIContent("Enable Passthrough", "Enables passthrough functionality for the scene. Can be toggled at runtime. Passthrough Capability must be enabled in the project settings.");
#else
        GUIContent enablePassthroughContent = new GUIContent("Enable Passthrough", "Enables passthrough functionality for the scene. Can be toggled at runtime.");
#endif
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Insight Passthrough", EditorStyles.boldLabel);
#if UNITY_ANDROID
        if (!passthroughCapabilityEnabled)
        {
            EditorGUILayout.LabelField("Requires Passthrough Capability to be enabled in the General section of the Quest features.", EditorStyles.wordWrappedLabel);
        }
#endif
        OVREditorUtil.SetupBoolField(target, enablePassthroughContent, ref manager.isInsightPassthroughEnabled, ref modified);
#if UNITY_ANDROID
        EditorGUI.EndDisabledGroup();
#endif
#endif

        if (modified)
        {
            EditorUtility.SetDirty(target);
        }
    }
Ejemplo n.º 4
0
    private static void ApplyFeatureManfiestTags(XmlDocument doc, string androidNamespaceURI, bool modifyIfFound)
    {
        OVRProjectConfig   projectConfig   = OVRProjectConfig.GetProjectConfig();
        OVRRuntimeSettings runtimeSettings = OVRRuntimeSettings.GetRuntimeSettings();

        //============================================================================
        // Hand Tracking
        // If Quest is the target device, add the handtracking manifest tags if needed
        // Mapping of project setting to manifest setting:
        // OVRProjectConfig.HandTrackingSupport.ControllersOnly => manifest entry not present
        // OVRProjectConfig.HandTrackingSupport.ControllersAndHands => manifest entry present and required=false
        // OVRProjectConfig.HandTrackingSupport.HandsOnly => manifest entry present and required=true
        OVRProjectConfig.HandTrackingSupport targetHandTrackingSupport = OVRProjectConfig.GetProjectConfig().handTrackingSupport;
        bool handTrackingEntryNeeded = OVRDeviceSelector.isTargetDeviceQuestFamily && (targetHandTrackingSupport != OVRProjectConfig.HandTrackingSupport.ControllersOnly);

        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest",
                       "uses-feature",
                       "oculus.software.handtracking",
                       handTrackingEntryNeeded,
                       modifyIfFound,
                       "required", (targetHandTrackingSupport == OVRProjectConfig.HandTrackingSupport.HandsOnly) ? "true" : "false");
        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest",
                       "uses-permission",
                       "com.oculus.permission.HAND_TRACKING",
                       handTrackingEntryNeeded,
                       modifyIfFound);

        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest/application",
                       "meta-data",
                       "com.oculus.handtracking.frequency",
                       handTrackingEntryNeeded,
                       modifyIfFound,
                       "value", projectConfig.handTrackingFrequency.ToString());

        //============================================================================
        // System Keyboard
        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest",
                       "uses-feature",
                       "oculus.software.overlay_keyboard",
                       projectConfig.requiresSystemKeyboard,
                       modifyIfFound,
                       "required", "false");

        //============================================================================
        // Experimental Features
        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest",
                       "uses-feature",
                       "com.oculus.experimental.enabled",
                       projectConfig.experimentalFeaturesEnabled,
                       modifyIfFound,
                       "required", "true");

        //============================================================================
        // Spatial Anchors
        OVRProjectConfig.SpatialAnchorsSupport targetSpatialAnchorsSupport = OVRProjectConfig.GetProjectConfig().spatialAnchorsSupport;
        bool spatialAnchorsEntryNeeded = OVRDeviceSelector.isTargetDeviceQuestFamily && (targetSpatialAnchorsSupport == OVRProjectConfig.SpatialAnchorsSupport.Enabled);

        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest",
                       "uses-permission",
                       "com.oculus.permission.USE_ANCHOR_API",
                       spatialAnchorsEntryNeeded,
                       modifyIfFound);

        //============================================================================
        // Passthrough
        AddOrRemoveTag(doc,
                       androidNamespaceURI,
                       "/manifest",
                       "uses-feature",
                       "com.oculus.feature.PASSTHROUGH",
                       projectConfig.insightPassthroughEnabled,
                       modifyIfFound,
                       "required", "true");

        //============================================================================
        // System Splash Screen
        if (projectConfig.systemSplashScreen != null)
        {
            AddOrRemoveTag(doc,
                           androidNamespaceURI,
                           "/manifest/application",
                           "meta-data",
                           "com.oculus.ossplash",
                           true,
                           modifyIfFound,
                           "value", "true");

            AddOrRemoveTag(doc,
                           androidNamespaceURI,
                           "/manifest/application",
                           "meta-data",
                           "com.oculus.ossplash.colorspace",
                           true,
                           modifyIfFound,
                           "value", ColorSpaceToManifestTag(runtimeSettings.colorSpace));
        }
    }