• Guides
    • English
    • 日本語
  • API Documentation
  • 機能概要
  • Multi Scene System
  • Monitoring Content Loading

    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

    Monitoring content loading

    Scene operation progress

    When content is being loaded or unloaded, the SceneOperationInProgress property will return true. You can monitor the progress of this operation via the SceneOperationProgress property.

    The SceneOperationProgress value is the average of all current async scene operations. At the start of a content load, SceneOperationProgress will be zero. Once fully completed, SceneOperationProgress will be set to 1 and will remain at 1 until the next operation takes place. Note that only content scene operations affect these properties.

    These properties reflect the state of an entire operation from start to finish, even if that operation includes multiple steps:

    IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
    
    // First do an additive scene load
    // SceneOperationInProgress will be true for the duration of this operation
    // SceneOperationProgress will show 0-1 as it completes
    await sceneSystem.LoadContent("ContentScene1");
    
    // Now do a single scene load
    // This will result in two actions back-to-back
    // First "ContentScene1" will be unloaded
    // Then "ContentScene2" will be loaded
    // SceneOperationInProgress will be true for the duration of this operation
    // SceneOperationProgress will show 0-1 as it completes
    sceneSystem.LoadContent("ContentScene2", LoadSceneMode.Single)
    

    Progress examples

    SceneOperationInProgress can be useful if activity should be suspended while content is being loaded:

    public class FooManager : MonoBehaviour
    {
        private void Update()
        {
            IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
    
            // Don't update foos while a scene operation is in progress
            if (sceneSystem.SceneOperationInProgress)
            {
                return;
            }
    
            // Update foos
            ...
        }
        ...
    }
    

    SceneOperationProgress can be used to display progress dialogs:

    public class ProgressDialog : MonoBehaviour
    {
        private void Update()
        {
            IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
    
            if (sceneSystem.SceneOperationInProgress)
            {
                DisplayProgressIndicator(sceneSystem.SceneOperationProgress);
            }
            else
            {
                HideProgressIndicator();
            }
        }
        ...
    }
    

    Monitoring with actions

    The Scene System provides several actions to let you know when scenes are being loaded or unloaded. Each action relays the name of the affected scene.

    If a load or unload operation involves multiple scenes, the relevant actions will be invoked once per affected scene. They are also invoked all at once when the load or unload operation is fully completed. For this reason it's recommended that you use OnWillUnload actions to detect content that will be destroyed, as opposed to using OnUnloaded actions to detect destroyed content after the fact.

    On the flip side, because OnLoaded actions are only invoked when all scenes are activated and fully loaded, using OnLoaded actions to detect and use new content is guaranteed to be safe.

    Action When it's invoked Content Scenes Lighting Scenes Manager Scenes
    OnWillLoadContent Just prior to a content scene load •
    OnContentLoaded After all content scenes in a load operation have been fully loaded and activated •
    OnWillUnloadContent Just prior to a content scene unload operation •
    OnContentUnloaded After all content scenes in an unload operation have been fully unloaded •
    OnWillLoadLighting Just prior to a lighting scene load •
    OnLightingLoaded After a lighting scene has been fully loaded and activated •
    OnWillUnloadLighting Just prior to a lighting scene unload •
    OnLightingUnloaded After a lighting scene has been fully unloaded •
    OnWillLoadScene Just prior to a scene load • • •
    OnSceneLoaded After all scenes in an operation are fully loaded and activated • • •
    OnWillUnloadScene Just prior to a scene unload • • •
    OnSceneUnloaded After a scene is fully unloaded • • •

    Action examples

    Another progress dialog example using actions and a coroutine instead of Update:

    public class ProgressDialog : MonoBehaviour
    {
        private bool displayingProgress = false;
    
        private void Start()
        {
            IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
            sceneSystem.OnWillLoadContent += HandleSceneOperation;
            sceneSystem.OnWillUnloadContent += HandleSceneOperation;
        }
    
        private void HandleSceneOperation (string sceneName)
        {
            // This may be invoked multiple times per frame - once per scene being loaded or unloaded.
            // So filter the events appropriately.
            if (displayingProgress)
            {
                return;
            }
    
            displayingProgress = true;
            StartCoroutine(DisplayProgress());
        }
    
        private IEnumerator DisplayProgress()
        {
            IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
    
            while (sceneSystem.SceneOperationInProgress)
            {
                DisplayProgressIndicator(sceneSystem.SceneOperationProgress);
                yield return null;
            }
    
            HideProgressIndicator();
            displayingProgress = false;
        }
    
        ...
    }
    

    Controlling scene activation

    By default content scenes are set to activate when loaded. If you want to control scene activation manually, you can pass a SceneActivationToken to any content load method. If multiple content scenes are being loaded by a single operation, this activation token will apply to all scenes.

    IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
    
    SceneActivationToken activationToken = new SceneActivationToken();
    
    // Load the content and pass the activation token
    sceneSystem.LoadContent(new string[] { "ContentScene1", "ContentScene2", "ContentScene3" }, LoadSceneMode.Additive, activationToken);
    
    // Wait until all users have joined the experience
    while (!AllUsersHaveJoinedExperience())
    {
        await Task.Yield();
    }
    
    // Let scene system know we're ready to activate all scenes
    activationToken.AllowSceneActivation = true;
    
    // Wait for all scenes to be fully loaded and activated
    while (sceneSystem.SceneOperationInProgress)
    {
        await Task.Yield();
    }
    
    // Proceed with experience
    

    Checking which content is loaded

    The ContentSceneNames property provides an array of available content scenes in order of build index. You can check whether these scenes are loaded via IsContentLoaded(string contentName).

    IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>();
    
    string[] contentSceneNames = sceneSystem.ContentSceneNames;
    bool[] loadStatus = new bool[contentSceneNames.Length];
    
    for (int i = 0; i < contentSceneNames.Length; i++>)
    {
        loadStatus[i] = sceneSystem.IsContentLoaded(contentSceneNames[i]);
    }
    
    • Improve this Doc
    In This Article
    • Scene operation progress
      • Progress examples
    • Monitoring with actions
      • Action examples
    • Controlling scene activation
    • Checking which content is loaded
    Back to top Generated by DocFX