• Guides
    • English
    • 日本語
  • API Documentation
  • 機能概要
  • Extension Services
  • Scene Transition Service Overview

    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

    Scene transition service

    This extension simplifies the business of fading out a scene, displaying a progress indicator, loading a scene, then fading back in.

    Scene operations are driven by the SceneSystem service, but any Task-based operation can be used to drive a transition.

    Enabling the extension

    To enable the extension, open your RegisteredServiceProvider profile. Click Register a new Service Provider to add a new configuration. In the Component Type field, select SceneTransitionService. In the Configuration Profile field, select the default scene transition profile included with the extension.

    Profile options

    Use default progress indicator

    If checked, the default progress indicator prefab will be used when no progress indicator object is provided when calling DoSceneTransition. If a progress indicator object is provided, the default will be ignored.

    Use fade color

    If checked, the transition service will apply a fade during your transition. This setting can be changed at runtime via the service's UseFadeColor property.

    Fade color

    Controls the color of the fade effect. Alpha is ignored. This setting can be changed at runtime prior to a transition via the service's FadeColor property.

    Fade targets

    Controls which cameras will have a fade effect applied to them. This setting can be changed at runtime via the service's FadeTargets property.

    Setting Targeted Cameras
    Main Applies fade effect to the main camera.
    UI Applies fade effect to cameras on the UI layer. (Does not affect overlay UI)
    All Applies to both main and UI cameras.
    Custom Applies to a custom set of cameras provided via SetCustomFadeTargetCameras

    Fade out time / fade in time

    Default settings for the duration of a fade on entering / exiting a transition. These settings can be changed at runtime via the service's FadeOutTime and FadeInTime properties.

    Camera fader type

    Which ICameraFader class to use for applying a fade effect to cameras. The default CameraFaderQuad class instantiates a quad with a transparent material in front of the target camera close to the clip plane. Another approach might be to use a post effects system.

    Using the extension

    You use the transition service by passing Tasks that are run while the camera is faded out.

    Using scene system tasks

    In most cases you will be using Tasks supplied by the SceneSystem service:

    private async void TransitionToScene()
    {
        IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
        ISceneTransitionService transition = MixedRealityToolkit.Instance.GetService<ISceneTransitionService>();
    
        // Fades out
        // Runs LoadContent task
        // Fades back in
        await transition.DoSceneTransition(
                () => sceneSystem.LoadContent("TestScene1")
            );
    }
    

    Using custom tasks

    In other cases you may want to perform a transition without actually loading a scene:

    private async void TransitionToScene()
    {
        ISceneTransitionService transition = MixedRealityToolkit.Instance.GetService<ISceneTransitionService>();
    
        // Fades out
        // Resets scene
        // Fades back in
        await transition.DoSceneTransition(
                () => ResetScene()
            );
    }
    
    private async Task ResetScene()
    {
        // Go through all enemies in the current scene and move them back to starting positions
    }
    

    Or you may want to load a scene without using the SceneSystem service:

    private async void TransitionToScene()
    {
        ISceneTransitionService transition = MixedRealityToolkit.Instance.GetService<ISceneTransitionService>();
    
        // Fades out
        // Loads scene using Unity's scene manager
        // Fades back in
        await transition.DoSceneTransition(
                () => LoadScene("TestScene1")
            );
    }
    
    private async Task LoadScene(string sceneName)
    {
        AsyncOperation asyncOp = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
        while (!asyncOp.isDone)
        {
            await Task.Yield();
        }
    }
    

    Using multiple tasks

    You can also supply multiple tasks, which will be executed in order:

    private async void TransitionToScene()
    {
        IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
        ISceneTransitionService transition = MixedRealityToolkit.Instance.GetService<ISceneTransitionService>();
    
        // Fades out
        // Sets time scale to 0
        // Fades out audio to 0
        // Loads TestScene1
        // Fades in audio to 1
        // Sets time scale to 1
        // Fades back in
        await transition.DoSceneTransition(
                () => SetTimescale(0f),
                () => FadeAudio(0f, 1f),
                () => sceneSystem.LoadContent("TestScene1"),
                () => FadeAudio(1f, 1f),
                () => SetTimescale(1f)
            );
    }
    
    private async Task SetTimescale(float targetTime)
    {
        Time.timeScale = targetTime;
        await Task.Yield();
    }
    
    private async Task FadeAudio(float targetVolume, float duration)
    {
        float startTime = Time.realtimeSinceStartup;
        float startVolume = AudioListener.volume;
        while (Time.realtimeSinceStartup < startTime + duration)
        {
            AudioListener.volume = Mathf.Lerp(startVolume, targetVolume, Time.realtimeSinceStartup - startTime / duration);
            await Task.Yield();
           }
           AudioListener.volume = targetVolume;
    }
    

    Using the progress indicator

    A progress indicator is anything that implements the IProgressIndicator interface. This can take the form of a splash screen, a 3D tagalong loading indicator, or anything else that provides feedback about transition progress.

    If UseDefaultProgressIndicator is checked in the SceneTransitionService profile, a progress indicator will be instantiated when a transition begins. For the duration of the transition this indicator's Progress and Message properties can be accessed via that service's SetProgressValue and SetProgressMessage methods.

    private async void TransitionToScene()
    {
        IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
        ISceneTransitionService transition = MixedRealityToolkit.Instance.GetService<ISceneTransitionService>();
    
        ListenToSceneTransition(sceneSystem, transition);
    
        await transition.DoSceneTransition(
                () => sceneSystem.LoadContent("TestScene1")
            );
    }
    
    private async void ListenToSceneTransition(IMixedRealitySceneSystem sceneSystem, ISceneTransitionService transition)
    {
        transition.SetProgressMessage("Starting transition...");
    
        while (transition.TransitionInProgress)
        {
            if (sceneSystem.SceneOperationInProgress)
            {
                transition.SetProgressMessage("Loading scene...");
                transition.SetProgressValue(sceneSystem.SceneOperationProgress);
            }
            else
            {
                transition.SetProgressMessage("Finished loading scene...");
                transition.SetProgressValue(1);
            }
    
            await Task.Yield();
        }
    }
    

    Alternatively, when calling DoSceneTransition you can supply your own progress indicator via the optional progressIndicator argument. This will override the default progress indicator.

    • Improve this Doc
    In This Article
    • Enabling the extension
    • Profile options
      • Use default progress indicator
      • Use fade color
      • Fade color
      • Fade targets
      • Fade out time / fade in time
      • Camera fader type
    • Using the extension
      • Using scene system tasks
      • Using custom tasks
      • Using multiple tasks
    • Using the progress indicator
    Back to top Generated by DocFX