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"만 인쇄한다고 생각합니다. 내 위치 설정에서 위치를 사용할 수 있습니다.왜 유니티 내 위치를 사용 할 수 없습니다?
Unity 용 토글 스위치가 없습니다. Unity 내에서 활성화해야 할 설정이 있습니까? –
시도해 볼 수 있습니다. 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