Unity XR SDK は、Unity で動作する独自の XR プロバイダーを開発したいと考えている専門家ユーザーを対象としています。XR SDK をダウンロードするには、このページ でアクセスのためのサインアップが必要です。
XR SDK パッケージを使うと、複数のバックエンド (“プロバイダー” と呼ばれます) が、単一のエンジン機能 (“サブシステム” と呼ばれます) を Unity に実装することが可能になります。ユーザーアプリケーションは、ランタイムにプロバイダーを選択し有効にすることができます。
サブシステムは以下から構成されています。
サブシステム記述子は、サブシステムをロードまたは初期化する前に検査するサブシステムに関するメタデータです。これはマニフェストファイルから来ており、C# インターフェースを通してアクセスできます。Create
メソッドは、サブシステムをアクティブ化して、そのインスタンスをユーザーのスクリプトに提供します。
詳細については、ランタイムディスカバリーとサブシステムのアクティベーション のページを参照してください。
サブシステム記述子で Create
が呼び出されると、これによりサブシステムのインスタンスが作成されます。スクリプトコードは、サブシステムと通信するためにこれらのインスタンスと相互作用します。サブシステム自体には独自のライフサイクル (起動、停止、シャットダウン) があります。
プロバイダーは、サブシステムのネイティブな実装です。1 つのサブシステムが複数のプロバイダーを持つことができます。サブシステムの中には、一度に複数のプロバイダーをアクティブにできるものもありますが、相互に排他的なものもあります。
プロバイダーは、Unity のネイティブプラグインインターフェース に準拠しており、その上にいくつかの追加のライフサイクルサポートが構築されています。エントリーポイントは、UnityPluginLoad
メソッドです。ここから先は、プロバイダーが実装しようとするすべてのサブシステムに登録する必要があります。
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API
UnityPluginLoad(IUnityInterfaces* unityInterfaces)
{
s_XrDisplay = unityInterfaces->Get<IUnityXRDisplayInterface>();
UnityLifecycleProvider displayLifecycleHandler =
{
NULL, // これは、 userData として以下の関数に渡される任意のオブジェクトです
&Lifecycle_Initialize,
&Lifecycle_Start,
&Lifecycle_Stop,
&Lifecycle_Shutdown
};
s_XrDisplay->RegisterLifecycleProvider("Provider Plugin Name", "Display0", &displayLifecycleHandler);
// 他のサブシステムに登録...
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.