3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MixedReality-WebRTCをPackagesからAssetsに移動する

Last updated at Posted at 2021-08-26

目的

  • MixedReality-WebRTC Unity用ライブラリのソースコードの解析したい
  • MixedReality-WebRTCのサンプルシーンを閲覧したい
  • Packages以下だと作業しづらい&シーンが開けないので、Assets以下に移動する

環境

  • Windows 10
  • Unity 2020.3.14f1
  • MixedRealityFeatureTool-1.0.2104.4-Beta
  • MixedReality-WebRTC 2.0.2

MRTK WebRTCをインストール

  • MixedRealityFeatureToolを使って、MixedReality-WebRTCをインストール
  • manifest.json に以下の2行が追加される
{
  "dependencies": {
    "com.microsoft.mixedreality.webrtc": "file:MixedReality/com.microsoft.mixedreality.webrtc-2.0.2.tgz",
    "com.microsoft.mixedreality.webrtc.samples": "file:MixedReality/com.microsoft.mixedreality.webrtc.samples-2.0.2.tgz"
  }
}
  • 以下の2ファイルが作成される
%PROJECT_PATH%\Packages\MixedReality

com.microsoft.mixedreality.webrtc-2.0.2.tgz
com.microsoft.mixedreality.webrtc.samples-2.0.2.tgz

参考

  • MixedRealityFeatureToolの使い方

トラブル「サンプルシーンが開けない」

  • Packages以下にサンプルのシーンがあるようだが、
  • Unity 2020.xだと、Packages以下のシーンが開けないようだ

Packages から Assets に移動

  • 2つのtgzファイルを別の場所に保存する
  • manifest.json の2行を削除する
  • 2つのtgzを展開して、Assets 以下に移動(エクスプローラーでファイルを移動せず、Unity Editorにドラッグ&ドロップして移動)
    • WebRTCライブラリの方もソースコード解析しやすいように、Assets以下に移動
    • サンプルのシーンを開きたいだけならば、WebRTCライブラリはPackages以下(UPM管理)でよい

トラブル「WebRTCライブラリをPackagesからAssetsに移動するとエラーが発生」

  • com.microsoft.mixedreality.webrtc-2.0.2をAssets以下に移動後
  • PeerConnectionを付与したゲームオブジェクトをUnity Editorで開くと以下のエラーが発生する
NullReferenceException: Object reference not set to an instance of an object
Microsoft.MixedReality.WebRTC.Unity.Editor.PeerConnectionEditor.DrawSpriteIcon (Microsoft.MixedReality.WebRTC.Unity.Editor.PeerConnectionEditor+IconType type, UnityEngine.Rect rect) (at Assets/com.microsoft.mixedreality.webrtc-2.0.2/package/Editor/PeerConnectionEditor.cs:57)

対応方法

  • アイコンファイルの読み込みに失敗しているのでパスを修正する
Assets/com.microsoft.mixedreality.webrtc-2.0.2/package/Editor/PeerConnectionEditor.cs(L.74)

var objects = AssetDatabase.LoadAllAssetsAtPath("Assets/com.microsoft.mixedreality.webrtc-2.0.2/package/Editor/Icons/editor_icons.png");
//var objects = AssetDatabase.LoadAllAssetsAtPath("Packages/com.microsoft.mixedreality.webrtc/Editor/Icons/editor_icons.png");

課題

  • MixedReality-WebRTC C/C++側、C#側のライブラリのソースも解析したいが、どのようにするのがよいか現状、把握できていない
3
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?