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

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

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

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

Q&A

解決済

1回答

1799閲覧

Unity ビルドエラー

Sotamaki0421

総合スコア13

Unity

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

0グッド

0クリップ

投稿2019/06/08 12:12

編集2019/06/09 04:57

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 55 private GameObject obj; 56 57 public void Start() 58 { 59 obj = GameObject.Find("sawara3"); 60 obj.SetActive(false); 61 } 62 63 public void Update() 64 { 65 _UpdateApplicationLifecycle(); 66 67 // If the player has not touched the screen, we are done with this update. 68 Touch touch; 69 if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) 70 { 71 return; 72 } 73 74 // Should not handle input if the player is pointing on UI. 75 if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) 76 { 77 return; 78 } 79 80 // Raycast against the location the player touched to search for planes. 81 TrackableHit hit; 82 TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon | 83 TrackableHitFlags.FeaturePointWithSurfaceNormal; 84 85 if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit)) 86 { 87 // Use hit pose and camera pose to check if hittest is from the 88 // back of the plane, if it is, no need to create the anchor. 89 if ((hit.Trackable is DetectedPlane) && 90 Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position, 91 hit.Pose.rotation * Vector3.up) < 0) 92 { 93 Debug.Log("Hit at back of the current DetectedPlane"); 94 } 95 else 96 { 97 // Choose the Andy model for the Trackable that got hit. 98 GameObject prefab; 99 if (hit.Trackable is FeaturePoint) 100 { 101 prefab = AndyPointPrefab; 102 } 103 else 104 { 105 prefab = AndyPlanePrefab; 106 } 107 108 // Instantiate Andy model at the hit pose. 109 var andyObject = Instantiate(prefab, hit.Pose.position, hit.Pose.rotation); 110 111 // Compensate for the hitPose rotation facing away from the raycast (i.e. 112 // camera). 113 obj.transform.Rotate(0, k_ModelRotation, 0, Space.Self); 114 115 // Create an anchor to allow ARCore to track the hitpoint as understanding of 116 // the physical world evolves. 117 var anchor = hit.Trackable.CreateAnchor(hit.Pose); 118 119 obj.SetActive(true); 120 obj.transform.position = hit.Pose.position; 121 122 // Make Andy model a child of the anchor. 123 andyObject.transform.parent = anchor.transform; 124 } 125 } 126 } 127 128 /// <summary> 129 /// Check and update the application lifecycle. 130 /// </summary> 131 private void _UpdateApplicationLifecycle() 132 { 133 // Exit the app when the 'back' button is pressed. 134 if (Input.GetKey(KeyCode.Escape)) 135 { 136 Application.Quit(); 137 } 138 139 // Only allow the screen to sleep when not tracking. 140 if (Session.Status != SessionStatus.Tracking) 141 { 142 const int lostTrackingSleepTimeout = 15; 143 Screen.sleepTimeout = lostTrackingSleepTimeout; 144 } 145 else 146 { 147 Screen.sleepTimeout = SleepTimeout.NeverSleep; 148 } 149 150 if (m_IsQuitting) 151 { 152 return; 153 } 154 155 // Quit if ARCore was unable to connect and give Unity some time for the toast to 156 // appear. 157 if (Session.Status == SessionStatus.ErrorPermissionNotGranted) 158 { 159 _ShowAndroidToastMessage("Camera permission is needed to run this application."); 160 m_IsQuitting = true; 161 Invoke("_DoQuit", 0.5f); 162 } 163 else if (Session.Status.IsError()) 164 { 165 _ShowAndroidToastMessage( 166 "ARCore encountered a problem connecting. Please start the app again."); 167 m_IsQuitting = true; 168 Invoke("_DoQuit", 0.5f); 169 } 170 } 171 172 173 174 /// <summary> 175 /// Actually quit the application. 176 /// </summary> 177 private void _DoQuit() 178 { 179 Application.Quit(); 180 } 181 182 /// <summary> 183 /// Show an Android toast message. 184 /// </summary> 185 /// <param name="message">Message string to show in the toast.</param> 186 private void _ShowAndroidToastMessage(string message) 187 { 188 AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 189 AndroidJavaObject unityActivity = 190 unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); 191 192 if (unityActivity != null) 193 { 194 AndroidJavaClass toastClass = new AndroidJavaClass("android.widget.Toast"); 195 unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() => 196 { 197 AndroidJavaObject toastObject = 198 toastClass.CallStatic<AndroidJavaObject>( 199 "makeText", unityActivity, message, 0); 200 toastObject.Call("show"); 201 })); 202 } 203 } 204 } 205} 206 207```エラー⑴ 208FormatException: Input string was not in a correct format. 209 210 211エラー⑵ 212Error building Player: FormatException: Input string was not in a correct format. 213 214 215エラー⑶ 216Build completed with a result of 'Failed' 217UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) 218 219 220エラー⑷ 221UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors 222 223 at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00242] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:194 224 225 at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:97 226UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) 227 228UnityでつくったゲームをAndroidStudioでビルドした際に上記のようなエラーが発生したのですがどのように解決したらよいですか?

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

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

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

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

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

y_waiwai

2019/06/08 13:58

コードを提示しましょう
fiveHundred

2019/06/09 00:14

他にエラーが無いか確認してください。 (Consoleウィンドウから確認できます)
guest

回答1

0

ベストアンサー

Unityのバージョンはいくつですか?
こちらこちらによると、2019.3.0a1でのみ発生するバグだそうなので、その場合はバージョンを下げると直るかもしれません。
バージョン名に「a」が付いているものはアルファ版らしいので、「f」が付いているバージョンを使うことをおすすめします。

投稿2019/06/09 03:38

fiveHundred

総合スコア9803

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

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

Sotamaki0421

2019/06/09 04:59

2019.3.0a5から2019.1.5f1に変更した結果、上記のようなエラー内容に変わりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問