Created
June 23, 2024 11:08
-
-
Save flushpot1125/cf6fa04cb5cc23afe490db3e0406c1ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Copied from "https://qiita.com/lycoris102/items/35e338b32105879e0ab9" | |
using UnityEngine; | |
using System.Collections; | |
public class LocationUpdater : MonoBehaviour | |
{ | |
public float IntervalSeconds = 1.0f; | |
public LocationServiceStatus Status; | |
public LocationInfo Location; | |
IEnumerator Start() | |
{ | |
while (true) | |
{ | |
this.Status = Input.location.status; | |
if (Input.location.isEnabledByUser) | |
{ | |
switch(this.Status) | |
{ | |
case LocationServiceStatus.Stopped: | |
Input.location.Start(); | |
break; | |
case LocationServiceStatus.Running: | |
this.Location = Input.location.lastData; | |
break; | |
default: | |
break; | |
} | |
} | |
else | |
{ | |
// FIXME 位置情報を有効にして!! 的なダイアログの表示処理を入れると良さそう | |
Debug.Log("location is disabled by user"); | |
} | |
// 指定した秒数後に再度判定を走らせる | |
yield return new WaitForSeconds(IntervalSeconds); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment