Advertisement
Rainmaker31

LocationGps2

May 26th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. public class gpslocation1 : MonoBehaviour
  7. {
  8.  
  9. public float Latitude;
  10. public float Longitude;
  11.  
  12. private void Start()
  13. {
  14. if (Input.location.isEnabledByUser)
  15. StartCoroutine(GetLocation());
  16. }
  17. private IEnumerator GetLocation()
  18. {
  19. Input.location.Start();
  20. while (Input.location.status == LocationServiceStatus.Initializing)
  21. {
  22. yield return new WaitForSeconds(0.5f);
  23. }
  24. while (Input.location.status == LocationServiceStatus.Running)
  25. {
  26. Latitude = Input.location.lastData.latitude;
  27. Longitude = Input.location.lastData.longitude;
  28. yield return null;
  29. }
  30. yield return null;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement