質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
ARCore

ARCoreは、グーグル社が提供しているAndroid向けのAR(拡張現実)フレームワークです。スマホ内蔵のカメラとIMUセンサー(慣性計測装置)を使って、モーショントラッキングや水平面の検出、光源の推測を行い、ARを実現します。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

0回答

1462閲覧

Unity AndroidStudio ビルドエラー

Sotamaki0421

総合スコア13

ARCore

ARCoreは、グーグル社が提供しているAndroid向けのAR(拡張現実)フレームワークです。スマホ内蔵のカメラとIMUセンサー(慣性計測装置)を使って、モーショントラッキングや水平面の検出、光源の推測を行い、ARを実現します。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2019/06/09 12:55

UnityでARcoreパッケージをインポートした際にビルドエラーが発生しました。

C#

1namespace GoogleARCore.Examples.HelloAR 2{ 3 using System.Collections.Generic; 4 using GoogleARCore; 5 using GoogleARCore.Examples.Common; 6 using UnityEngine; 7 using UnityEngine.EventSystems; 8 9#if UNITY_EDITOR 10 // Set up touch input propagation while using Instant Preview in the editor. 11 using Input = InstantPreviewInput; 12#endif 13 14 /// <summary> 15 /// Controls the HelloAR example. 16 /// </summary> 17 public class HelloARController : MonoBehaviour 18 { 19 /// <summary> 20 /// The first-person camera being used to render the passthrough camera image (i.e. AR 21 /// background). 22 /// </summary> 23 public Camera FirstPersonCamera; 24 25 /// <summary> 26 /// A prefab for tracking and visualizing detected planes. 27 /// </summary> 28 public GameObject DetectedPlanePrefab; 29 30 /// <summary> 31 /// A model to place when a raycast from a user touch hits a plane. 32 /// </summary> 33 public GameObject AndyPlanePrefab; 34 35 /// <summary> 36 /// A model to place when a raycast from a user touch hits a feature point. 37 /// </summary> 38 public GameObject AndyPointPrefab; 39 40 /// <summary> 41 /// The rotation in degrees need to apply to model when the Andy model is placed. 42 /// </summary> 43 private const float k_ModelRotation = 180.0f; 44 45 /// <summary> 46 /// True if the app is in the process of quitting due to an ARCore connection error, 47 /// otherwise false. 48 /// </summary> 49 private bool m_IsQuitting = false; 50 51 /// <summary> 52 /// The Unity Update() method. 53 /// </summary> 54 public void Update() 55 { 56 _UpdateApplicationLifecycle(); 57 58 // If the player has not touched the screen, we are done with this update. 59 Touch touch; 60 if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) 61 { 62 return; 63 } 64 65 // Should not handle input if the player is pointing on UI. 66 if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) 67 { 68 return; 69 } 70 71 // Raycast against the location the player touched to search for planes. 72 TrackableHit hit; 73 TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon | 74 TrackableHitFlags.FeaturePointWithSurfaceNormal; 75 76 if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit)) 77 { 78 // Use hit pose and camera pose to check if hittest is from the 79 // back of the plane, if it is, no need to create the anchor. 80 if ((hit.Trackable is DetectedPlane) && 81 Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position, 82 hit.Pose.rotation * Vector3.up) < 0) 83 { 84 Debug.Log("Hit at back of the current DetectedPlane"); 85 } 86 else 87 { 88 // Choose the Andy model for the Trackable that got hit. 89 GameObject prefab; 90 if (hit.Trackable is FeaturePoint) 91 { 92 prefab = AndyPointPrefab; 93 } 94 else 95 { 96 prefab = AndyPlanePrefab; 97 } 98 99 // Instantiate Andy model at the hit pose. 100 var andyObject = Instantiate(prefab, hit.Pose.position, hit.Pose.rotation); 101 102 // Compensate for the hitPose rotation facing away from the raycast (i.e. 103 // camera). 104 andyObject.transform.Rotate(0, k_ModelRotation, 0, Space.Self); 105 106 // Create an anchor to allow ARCore to track the hitpoint as understanding of 107 // the physical world evolves. 108 var anchor = hit.Trackable.CreateAnchor(hit.Pose); 109 110 // Make Andy model a child of the anchor. 111 andyObject.transform.parent = anchor.transform; 112 } 113 } 114 } 115 116 /// <summary> 117 /// Check and update the application lifecycle. 118 /// </summary> 119 private void _UpdateApplicationLifecycle() 120 { 121 // Exit the app when the 'back' button is pressed. 122 if (Input.GetKey(KeyCode.Escape)) 123 { 124 Application.Quit(); 125 } 126 127 // Only allow the screen to sleep when not tracking. 128 if (Session.Status != SessionStatus.Tracking) 129 { 130 const int lostTrackingSleepTimeout = 15; 131 Screen.sleepTimeout = lostTrackingSleepTimeout; 132 } 133 else 134 { 135 Screen.sleepTimeout = SleepTimeout.NeverSleep; 136 } 137 138 if (m_IsQuitting) 139 { 140 return; 141 } 142 143 // Quit if ARCore was unable to connect and give Unity some time for the toast to 144 // appear. 145 if (Session.Status == SessionStatus.ErrorPermissionNotGranted) 146 { 147 _ShowAndroidToastMessage("Camera permission is needed to run this application."); 148 m_IsQuitting = true; 149 Invoke("_DoQuit", 0.5f); 150 } 151 else if (Session.Status.IsError()) 152 { 153 _ShowAndroidToastMessage( 154 "ARCore encountered a problem connecting. Please start the app again."); 155 m_IsQuitting = true; 156 Invoke("_DoQuit", 0.5f); 157 } 158 } 159 160 /// <summary> 161 /// Actually quit the application. 162 /// </summary> 163 private void _DoQuit() 164 { 165 Application.Quit(); 166 } 167 168 /// <summary> 169 /// Show an Android toast message. 170 /// </summary> 171 /// <param name="message">Message string to show in the toast.</param> 172 private void _ShowAndroidToastMessage(string message) 173 { 174 AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 175 AndroidJavaObject unityActivity = 176 unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); 177 178 if (unityActivity != null) 179 { 180 AndroidJavaClass toastClass = new AndroidJavaClass("android.widget.Toast"); 181 unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() => 182 { 183 AndroidJavaObject toastObject = 184 toastClass.CallStatic<AndroidJavaObject>( 185 "makeText", unityActivity, message, 0); 186 toastObject.Call("show"); 187 })); 188 } 189 } 190 } 191} 192

Unity2019.1.5f1
Androi Studio3.4.1
arcore-unity-sdk-v1.9.0.unitypackage

XR Legacy Input Helpers
Multiplayer HLAPIはインストールしました。

SDKはAndroid Studioのものをコピペ、JDKはAndroid Studioのjreを設定しました。PlatformもAndroidにswicthし、playersettingsでARcore supportedにチェック、MultithreadedRenderingのチェックを外し、会社名・アプリ名も任意のものに変更。APIの最小とターゲットレベルは実機のものに合わせました。外部スクリプトエディタはvisual Studio 2019を使っています。

それでも以下のエラーが出てしまいます。どなたか助けていただけないでしょうか。

エラー⑴
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors

at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00242] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:194

at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:97
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

エラー⑵
Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

エラー⑶
Error building Player: FormatException: Input string was not in a correct format.

エラー⑷
FormatException: Input string was not in a correct format.
System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)

よろしくお願いいたします

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問