• Guides
    • English
    • 日本語
  • API Documentation
  • 機能概要
  • Camera System
  • Camera Settings Providers
  • Creating a camera settings provider

    Show / Hide Table of Contents
    • MRTK を始める
      • Release Notes
      • MRTK Package Contents
      • Updating from earlier versions
      • HTK からの移植ガイド
      • MRTK のビルドとデプロイ
      • NuGet Packages
      • Getting started with MRTK and XR SDK
      • Performance
      • Hologram Stabilization (ホログラムの安定化)
    • アーキテクチャ
      • 全体像
      • フレームワークとランタイム
      • Input System (入力システム)
        • 用語
        • Core System
        • Controllers, Pointers, and Focus
      • Systems, Extension Services and Data Providers
    • 機能概要
      • Boundary System
        • Boundary System Overview
        • Configuring the Boundary Visualization
      • Camera System
        • Camera System Overview
        • Camera Settings Providers
          • Windows Mixed Reality Camera Settings
          • Unity AR Camera Settings [Experimental]
          • Creating a camera settings provider
      • Cross Platform Support
        • Configure MRTK for iOS and Android
      • プラットフォームの Capabilities (機能) を検出する
      • Diagnostics System (診断システム)
        • 診断システムの概要
        • 診断システムの構成
        • ビジュアル プロファイラーを使用する
      • Extension Services
        • Extension Service Creation Wizard
        • Scene Transition Service Overview
        • Hand Physics Service Overview
      • Input System (入力システム)
        • 入力の概要
        • Input Actions
        • Input Events
        • Input Providers
          • Input Providers Overview
          • Creating an input data provider
        • Controllers (コントローラー)
        • Eyes
        • Gaze (ゲイズ)
        • Gestures (ジェスチャ)
        • Hands
        • How to Add Near Interaction
        • エディター内入力シミュレーション
        • Pointers
        • Voice Input
          • Dictation (ディクテーション)
          • Speech (コマンドとコントロール)
      • Multi Scene System
        • Multi Scene System Overview
        • Scene Types
        • Content Scene Loading
        • Monitoring Content Loading
        • Lighting Scene Operations
      • パッケージ
        • MRTK パッケージ
        • MRTK Modularization
      • Profiles (プロファイル)
        • プロファイル概要
        • 設定ガイド
      • Rendering
        • Material Instance Overview
        • Shaders
          • MRTK Standard Shader
      • Services (サービス)
        • What makes a mixed reality feature
        • MixedRealityServiceRegistry と IMixedRealityServiceRegistrar とは何か
        • Extension services
      • Spatial Awareness System (空間認識システム)
        • Spatial Awareness (空間認識) 概要
        • Spatial Observers
          • Configuring Observers for Device
          • Configuring Observers for Editor
          • Controlling Observers via Code
          • Creating a custom Observer
      • Teleport System (テレポートシステム) 概要
      • ツール
        • Dependency Window (依存関係ウィンドウ)
        • Extension Service Creation Wizard
        • Holographic Remoting
        • Input Animation Recording
          • Input Animation File Format Specification
        • Optimize Window
        • Runtime tools
          • Controller Mapping tool
      • UX ビルディング ブロック
        • Interactable (インタラクタブル)
        • Button (ボタン)
        • Bounding Box
        • Object Manipulation (物体操作)
        • Sliders (スライダー)
        • Fingertip Visualization
        • App Bar
        • Object Collection (オブジェクトコレクション)
        • Slate (スレート)
        • System Keyboard (システム キーボード)
        • Tooltips (ツールチップ)
        • Solvers (ソルバー)
      • Example Scenes
        • Examples Hub
        • ハンド インタラクションのサンプル
        • アイ トラッキング インタラクションのサンプル
      • Experimental
        • Scrolling Object Collection
        • Hand Coach UX
        • Pulse Shader
    • Contributing
      • Contributing Overview
      • Coding Guidelines
      • Writing and Running Tests
      • Writing Documentation
      • Pull Requests
      • Experimental Features
      • Breaking Changes
      • How to use DocFX
    • Planning
      • Roadmap
    • Notice
    • Authors

    Creating a camera settings provider

    The Camera system is an extensible system for providing support for platform specific camera configurations. To add support for a new camera configuration, a custom settings provider may be required.

    Note

    The complete source code used in this example can be found in the MixedRealityToolkit.Extensions\Providers\Experimental\UnityAR folder after importing the Microsoft.MixedReality.Toolkit.Unity.Extensions package.

    Namespace and folder structure

    Data providers can be distributed in one of two ways:

    1. Third party add-ons
    2. Part of the Microsoft Mixed Reality Toolkit

    The approval process for submissions of new data providers to the MRTK will vary on a case-by-case basis and will be communicated at the time of the initial proposal. Proposals can be submitted by creating a new Feature Request type issue.

    Third party add-ons

    Namespace

    Data providers are required to have a namespace to mitigate potential name collisions. It is recommended that the namespace includes the following components.

    • Company name producing the add-on
    • Feature area

    For example, a camera settings provider created and shipped by the Contoso company may be "Contoso.MixedReality.Toolkit.Camera".

    Folder structure

    It is recommended that the source code for data providers be layed out in a folder hierarchy as shown in the following image.

    Example folder structure

    Where the ContosoCamera folder contains the implementation of the data provider, the Editor folder contains the inspector (and any other Unity editor specific code), and the Profiles folder contains one or more pre-made profile scriptable objects.

    MRTK submission

    Namespace

    If a camera settings provider is being submitted to the Mixed Reality Toolkit repository, the namespace must begin with Microsoft.MixedReality.Toolkit (ex: Microsoft.MixedReality.Toolkit.CameraSystem).

    Folder structure

    All code must be located in a folder beneath MixedRealityToolkit.Providers (ex: MixedRealityToolkit.Providers\UnityAR).

    Define the camera settings object

    The first step in creating a camera settings provider is determining the type of data (ex: meshes or planes) it will provide to applications.

    All spatial data objects must implement the IMixedRealityCameraSettingsProvider interface.

    Implement the settings provider

    Specify interface and/or base class inheritance

    All camera settings providers must implement the IMixedRealityCameraSettingsProvider interface, which specifies the minimum functionality required by the camera system. The MRTK foundation includes the BaseCameraSettingsProvider class which provides a default implementation of the required functionality.

    namespace namespace Microsoft.MixedReality.Toolkit.Experimental.UnityAR
    {
        public class UnityARCameraSettings : BaseCameraSettingsProvider
        { }
    }
    

    Apply the MixedRealityDataProvider attribute

    A key step in creating a camera settings provider is to apply the MixedRealityDataProvider attribute to the class. This step enables setting the default profile and platform(s) for the data provider, when selected in the Camera System profile as well as name, folder path, and more.

        [MixedRealityDataProvider(
            typeof(IMixedRealityCameraSystem),
            SupportedPlatforms.Android | SupportedPlatforms.IOS,
            "Unity AR Foundation Camera Settings",
            "UnityAR/Profiles/DefaultUnityARCameraSettingsProfile.asset",
            "MixedRealityToolkit.Providers")]
        public class UnityARCameraSettings : BaseCameraSettingsProvider
        { }
    

    Implement the IMixedRealityDataProvider methods

    Once the class has been defined, the next step is to provide the implementation of the IMixedRealityDataProvider interface.

    Note

    The BaseDataProvider class, via the BaseService class, provides empty implementations for IMixedRealityDataProvider methods. The details of these methods are generally data provider specific.

    The methods that should be implemented by the data provider are:

    • Destroy()
    • Disable()
    • Enable()
    • Initialize()
    • Reset()
    • Update()
    Note

    Not all settings providers will require implementations for all of these methods. It is highly recommended that Destroy() and Initialize() be implemented at a minimum.

    Implement the data provider logic

    The next step is to add the logic of the settings provider by implementing IMixedRealityCameraSettingsProvider. This portion of the data provider will typically be camera configuration specific.

    Create the profile and inspector

    In the Mixed Reality Toolkit, data providers are configured using profiles.

    Define the profile

    Profile contents should mirror the developer selectable configuration options. Any user configurable properties defined in each interface should also be contained with the profile.

    using UnityEngine.SpatialTracking;
    
    namespace namespace Microsoft.MixedReality.Toolkit.Experimental.UnityAR
    {
        [CreateAssetMenu(
            menuName = "Mixed Reality Toolkit/Profiles/Unity AR Camera Settings Profile",
            fileName = "UnityARCameraSettingsProfile",
            order = 100)]
        public class UnityARCameraSettingsProfile : BaseCameraSettingsProfile
        {
            [SerializeField]
            [Tooltip("The portion of the device (ex: color camera) from which to read the pose.")]
            private ArTrackedPose poseSource = TrackedPoseDriver.TrackedPose.ColorCamera;
    
            /// <summary>
            /// The portion of the device (ex: color camera) from which to read the pose.
            /// </summary>
            public ArTrackedPose PoseSource => poseSource;
    
            [SerializeField]
            [Tooltip("The type of tracking (position and/or rotation) to apply.")]
            private ArTrackingType trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition;
    
            /// <summary>
            /// The type of tracking (position and/or rotation) to apply.
            /// </summary>
            public ArTrackingType TrackingType => trackingType;
    
            [SerializeField]
            [Tooltip("Specifies when (during Update and/or just before rendering) to update the tracking of the pose.")]
            private ArUpdateType updateType = TrackedPoseDriver.UpdateType.UpdateAndBeforeRender;
    
            /// <summary>
            /// Specifies when (during Update and/or just before rendering) to update the tracking of the pose.
            /// </summary>
            public ArUpdateType UpdateType => updateType;
        }
    }
    

    The CreateAssetMenu attribute can be applied to the profile class to enable customers to create a profile instance using the Create > Assets > Mixed Reality Toolkit > Profiles menu.

    Implement the inspector

    Profile inspectors are the user interface for configuring and viewing profile contents. Each profile inspector should extend the BaseMixedRealityToolkitConfigurationProfileInspector class.

    The CustomEditor attribute informs Unity the type of asset to which the inspector applies.

    namespace namespace Microsoft.MixedReality.Toolkit.Experimental.UnityAR
    {
        [CustomEditor(typeof(UnityARCameraSettingsProfile))]
        public class UnityARCameraSettingsProfileInspector : BaseMixedRealityToolkitConfigurationProfileInspector
        { }
    }
    

    Create assembly definition(s)

    The Mixed Reality Toolkit uses assembly definition (.asmdef) files to specify dependencies between components as well as to assist Unity in reducing compilation time.

    It is recommended that assembly definition files are created for all data providers and their editor components.

    Using the folder structure in the earlier example, there would be two .asmdef files for the ContosoCamera data provider.

    The first assembly definition is for the data provider. For this example, it will be called ContosoCamera and will be located in the example's ContosoCamera folder. This assembly definition must specify a dependency on Microsoft.MixedReality.Toolkit and any other assemblies upon which it depends.

    The ContosoCameraEditor assembly definition will specify the profile inspector and any editor specific code. This file must be located in the root folder of the editor code. In this example, the file will be located in the ContosoCamera\Editor folder. This assembly definition will contain a reference to the ContosoCamera assembly as well as:

    • Microsoft.MixedReality.Toolkit
    • Microsoft.MixedReality.Toolkit.Editor.Inspectors
    • Microsoft.MixedReality.Toolkit.Editor.Utilities

    Register the data provider

    Once created, the data provider can be registered with the Camera system to be used in the application.

    Selecting the camera settings provider

    Packaging and distribution

    Data providers that are distributed as third party components have the specific details of packaging and distribution left to the preference of the developer. Likely, the most common solution will be to generate a .unitypackage and distribute via the Unity Asset Store.

    If a data provider is submitted and accepted as a part of the Microsoft Mixed Reality Toolkit package, the Microsoft MRTK team will package and distribute it as part of the MRTK offerings.

    See also

    • Camera System Overview
    • BaseCameraSettingsProvider class
    • IMixedRealityCameraSettingsProvider interface
    • IMixedRealityDataProvider interface
    • Improve this Doc
    In This Article
    • Namespace and folder structure
      • Third party add-ons
      • MRTK submission
    • Define the camera settings object
    • Implement the settings provider
      • Specify interface and/or base class inheritance
        • Apply the MixedRealityDataProvider attribute
      • Implement the IMixedRealityDataProvider methods
      • Implement the data provider logic
    • Create the profile and inspector
      • Define the profile
      • Implement the inspector
    • Create assembly definition(s)
    • Register the data provider
    • Packaging and distribution
    • See also
    Back to top Generated by DocFX