Example #1
0
        /// <inheritdoc/>
        public virtual void ApplyConfiguration()
        {
            // It is the responsibility of the camera settings provider to set the display settings (this allows overriding the
            // default values with per-camera provider values).
            MixedRealityCameraProfile cameraProfile = Service?.CameraProfile;

            if (cameraProfile == null)
            {
                return;
            }

            if (IsOpaque)
            {
                CameraCache.Main.clearFlags      = cameraProfile.CameraClearFlagsOpaqueDisplay;
                CameraCache.Main.nearClipPlane   = cameraProfile.NearClipPlaneOpaqueDisplay;
                CameraCache.Main.farClipPlane    = cameraProfile.FarClipPlaneOpaqueDisplay;
                CameraCache.Main.backgroundColor = cameraProfile.BackgroundColorOpaqueDisplay;
                QualitySettings.SetQualityLevel(cameraProfile.OpaqueQualityLevel, false);
            }
            else
            {
                CameraCache.Main.clearFlags      = cameraProfile.CameraClearFlagsTransparentDisplay;
                CameraCache.Main.backgroundColor = cameraProfile.BackgroundColorTransparentDisplay;
                CameraCache.Main.nearClipPlane   = cameraProfile.NearClipPlaneTransparentDisplay;
                CameraCache.Main.farClipPlane    = cameraProfile.FarClipPlaneTransparentDisplay;
                QualitySettings.SetQualityLevel(cameraProfile.TransparentQualityLevel, false);
            }
        }
Example #2
0
        /// <inheritdoc />
        public override void Initialize()
        {
            MixedRealityCameraProfile profile = ConfigurationProfile as MixedRealityCameraProfile;

            if ((GetDataProviders <IMixedRealityCameraSettingsProvider>().Count == 0) && (profile != null))
            {
                // Register the settings providers.
                for (int i = 0; i < profile.SettingsConfigurations.Length; i++)
                {
                    MixedRealityCameraSettingsConfiguration configuration = profile.SettingsConfigurations[i];

                    if (configuration.ComponentType?.Type == null)
                    {
                        // Incomplete configuration, do not try to register until a type is set in the profile.
                        continue;
                    }

                    object[] args = { this, configuration.ComponentName, configuration.Priority, configuration.SettingsProfile };

                    if (RegisterDataProvider <IMixedRealityCameraSettingsProvider>(
                            configuration.ComponentType.Type,
                            configuration.RuntimePlatform,
                            args))
                    {
                        // Apply the display settings
                        IMixedRealityCameraSettingsProvider provider = GetDataProvider <IMixedRealityCameraSettingsProvider>(configuration.ComponentName);
                        provider?.ApplyConfiguration();
                    }
                }
            }

            // Check to see if any providers were loaded.
            useFallbackBehavior = (GetDataProviders <IMixedRealityCameraSettingsProvider>().Count == 0);

            if (useFallbackBehavior)
            {
                cameraOpaqueLastFrame = IsOpaque;

                if (IsOpaque)
                {
                    ApplySettingsForOpaqueDisplay();
                }
                else
                {
                    ApplySettingsForTransparentDisplay();
                }

                // Ensure the camera is parented to the playspace which starts, unrotated, at the origin.
                MixedRealityPlayspace.Position = Vector3.zero;
                MixedRealityPlayspace.Rotation = Quaternion.identity;
                if (CameraCache.Main.transform.position != Vector3.zero)
                {
                    Debug.LogWarning($"The main camera is not positioned at the origin ({Vector3.zero}), experiences may not behave as expected.");
                }
                if (CameraCache.Main.transform.rotation != Quaternion.identity)
                {
                    Debug.LogWarning($"The main camera is configured with a non-zero rotation, experiences may not behave as expected.");
                }
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="profile"></param>
        public MixedRealityCameraSystem(MixedRealityCameraProfile profile)
            : base(profile)
        {
            this.profile      = profile;
            DefaultHeadHeight = profile.DefaultHeadHeight;

            if (profile.CameraRigType.Type == null)
            {
                throw new Exception("Camera rig type cannot be null!");
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="profile"></param>
 public MixedRealityCameraSystem(MixedRealityCameraProfile profile)
     : base(profile)
 {
     this.profile = profile;
 }