Unityで ARと言えば、AR Foundation の使用が増えていくかと思いますが。Unity で Google の AR Core を久々に直接使用してみて。。。急にたくさんのエラーに遭遇しました。
使用した Unityのバージョンは Unity 2019、エラーは以下のようなエラーです。
error CS0234: The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

今回は、この解決方法の説明となります。
【現象】
このエラーは Unity 2019以降で ARCoreをインポートすると発生します。実際はこのエラーを元に、大量にエラーが出てきます。
エラーメッセージ:
Assets\GoogleARCore\SDK\InstantPreview\Scripts\InstantPreviewManager.cs(33,23): error CS0234: The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

使用した Unityのバージョンは Unity 2019、エラーは以下のようなエラーです。
error CS0234: The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

今回は、この解決方法の説明となります。
【現象】
このエラーは Unity 2019以降で ARCoreをインポートすると発生します。実際はこのエラーを元に、大量にエラーが出てきます。
エラーメッセージ:
Assets\GoogleARCore\SDK\InstantPreview\Scripts\InstantPreviewManager.cs(33,23): error CS0234: The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

【原因・解決法】
ARCoreを Unity2019.1以降のバージョンにインポートする際、インポート前に以下の追加ステップが必要です。
ARCoreを Unity2019.1以降のバージョンにインポートする際、インポート前に以下の追加ステップが必要です。
Window > Package Manger から Package Manager を起動。

「Multiplayer HLAPI」を選択して「Install」ボタンをクリック。
(CloudAnchors のサンプルに使用。)

「XR Legacy Input Helpers」を選択して「Install」ボタンをクリック。(TrackedPoseDriver を使っている Instant Preview に使用。)

上記の手順は、Googleの ARCoreの使用手順に書かれています。

「Multiplayer HLAPI」を選択して「Install」ボタンをクリック。
(CloudAnchors のサンプルに使用。)

「XR Legacy Input Helpers」を選択して「Install」ボタンをクリック。(TrackedPoseDriver を使っている Instant Preview に使用。)

上記の手順は、Googleの ARCoreの使用手順に書かれています。
上記の 2つのパッケージをインポートすれば、大量のエラーがいっきになくなります。


Sponsored Link