2016-08-01 2 views
0

Unity 3D 게임에서 위치 서비스를 사용하고 있습니다. 나는 테스트 목적으로 Unity 문서에서 찾은 (약간 수정 된)이 스크립트를 사용하고 있습니다.Unity에서 위치 사용이 허용되지 않습니다 - Windows 10

using UnityEngine; 
using System.Collections; 

public class TestLocationService : MonoBehaviour 
{ 
    IEnumerator Start() 
    { 
     // First, check if user has location service enabled 
     if (!Input.location.isEnabledByUser) 
      print("no"); 
      yield break; 

      // Start service before querying location 
      Input.location.Start(); 

      // Wait until service initializes 
      int maxWait = 20; 
     while (Input.location.status == LocationServiceStatus.Initializing  && maxWait > 0) 
    { 
     yield return new WaitForSeconds(1); 
     maxWait--; 
    } 

    // Service didn't initialize in 20 seconds 
    if (maxWait < 1) 
    { 
     print("Timed out"); 
     yield break; 
    } 

    // Connection has failed 
    if (Input.location.status == LocationServiceStatus.Failed) 
    { 
     print("Unable to determine device location"); 
     yield break; 
    } 
    else 
    { 
     // Access granted and location value could be retrieved 
     print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp); 
    } 

    // Stop service if there is no need to query location updates continuously 
    Input.location.Stop(); 
} 

가}

I 스크립트를 실행

이, 내 위치를 인쇄하도록되어 다음은 스크립트입니다. 그러나 위치 서비스가 활성화되지 않았으며 (Windows 10을 사용 중입니다) 중지하기 전에 "no"만 인쇄한다고 생각합니다. 내 위치 설정에서 위치를 사용할 수 있습니다.

enter image description here

왜 유니티 내 위치를 사용 할 수 없습니다?

답변

0

귀하는 Unity에게 위치 서비스를 사용할 수있는 권한을 부여해야합니다. 게시 한 스크린 샷을 아래로 스크롤하면 Unity의 스위치도 전환해야합니다.

그래도 작동하지 않는다면 일종의 지역 센서를 설치하고 어떤 차이가 있는지 확인해보십시오. http://answers.unity3d.com/questions/1219218/windows-10-using-location-with-unity-through-pc-no.html API를 Input.location.isEnabledByUser을 바탕으로

만에 (핸드 헬드 장치 만 해당) 유니티에서

+0

Unity 용 토글 스위치가 없습니다. Unity 내에서 활성화해야 할 설정이 있습니까? –

+0

시도해 볼 수 있습니다. http://www.tenforums.com/attachments/drivers-hardware/50767d1438836176t-find-my-device-wifi-feature-set-up-page-says-off-28806d1438836176-location-service-turn- off-windows-10-location_on_for_device-1.png – Aleks

관련 문제