unity通过GPS定位
来源:互联网 发布:天数倒计时软件 编辑:程序博客网 时间:2024/05/21 16:22
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.Xml;
using System.IO;
using System.Text;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour {
public string gps_info = "";
public int flash_num = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
GUI.skin.label.fontSize = 25;
GUI.Label (new Rect (20, 20, 600, 48), this.gps_info);
GUI.Label (new Rect (20, 50, 600, 48), this.flash_num.ToString());
GUI.skin.button.fontSize = 50;
if (GUI.Button(new Rect(Screen.width/2-110,200,220,85),"GPS定位")) {
StartCoroutine ("StartGPS");
}
if (GUI.Button(new Rect(Screen.width/2-110,500,220,85),"刷新GPS")) {
this.gps_info = "N" + Input.location.lastData.latitude + "E" + Input.location.lastData.longitude;
this.gps_info = gps_info + "Time" + Input.location.lastData.timestamp;
this.flash_num += 1;
}
}
void StopGPS(){
Input.location.Stop ();
}
IEnumerator StartGPS(){
if (!Input.location.isEnabledByUser) {
this.gps_info = "isEnabledByUser value is:" + Input.location.isEnabledByUser.ToString() + "Please trun on this GPS";
//return false;
}
Input.location.Start (10.0f,10.0f);
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait >0) {
yield return new WaitForSeconds (1);
maxWait--;
}
if (maxWait<1) {
this.gps_info = "Init GPS service time out";
//return false;
}
if (Input.location.status == LocationServiceStatus.Failed) {
this.gps_info = "Unable to determine device location";
//return false;
} else {
this.gps_info = "N:" + Input.location.lastData.latitude + "E:" + Input.location.lastData.longitude;
this.gps_info = this.gps_info + "Time:" + Input.location.lastData.timestamp;
yield return new WaitForSeconds (100);
}
}
}
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.Xml;
using System.IO;
using System.Text;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour {
public string gps_info = "";
public int flash_num = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
GUI.skin.label.fontSize = 25;
GUI.Label (new Rect (20, 20, 600, 48), this.gps_info);
GUI.Label (new Rect (20, 50, 600, 48), this.flash_num.ToString());
GUI.skin.button.fontSize = 50;
if (GUI.Button(new Rect(Screen.width/2-110,200,220,85),"GPS定位")) {
StartCoroutine ("StartGPS");
}
if (GUI.Button(new Rect(Screen.width/2-110,500,220,85),"刷新GPS")) {
this.gps_info = "N" + Input.location.lastData.latitude + "E" + Input.location.lastData.longitude;
this.gps_info = gps_info + "Time" + Input.location.lastData.timestamp;
this.flash_num += 1;
}
}
void StopGPS(){
Input.location.Stop ();
}
IEnumerator StartGPS(){
if (!Input.location.isEnabledByUser) {
this.gps_info = "isEnabledByUser value is:" + Input.location.isEnabledByUser.ToString() + "Please trun on this GPS";
//return false;
}
Input.location.Start (10.0f,10.0f);
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait >0) {
yield return new WaitForSeconds (1);
maxWait--;
}
if (maxWait<1) {
this.gps_info = "Init GPS service time out";
//return false;
}
if (Input.location.status == LocationServiceStatus.Failed) {
this.gps_info = "Unable to determine device location";
//return false;
} else {
this.gps_info = "N:" + Input.location.lastData.latitude + "E:" + Input.location.lastData.longitude;
this.gps_info = this.gps_info + "Time:" + Input.location.lastData.timestamp;
yield return new WaitForSeconds (100);
}
}
}
0 1
- unity通过GPS定位
- unity 定位服务GPS API
- 【Unity】使用GPS定位经纬度
- Unity之GPS定位详解
- Android 通过GPS进行定位
- Unity ios平台GPS地址位置定位
- Unity ios平台GPS地址位置定位
- Unity内部类实现GPS定位
- 通过gps,wifi,基站定位获取当前位置
- 百度地图通过GPS定位导航
- GPS定位
- GPS定位
- GPS定位
- GPS定位
- GPS定位
- gps定位
- GPS定位
- GPS定位
- bzoj2049洞穴勘测(lct模板题,lct详解)
- h5 第四课表格
- 生日卡片-我的第一个安卓程序
- python-sys模块
- 05. Oracle 11g 查看和修改日志模式
- unity通过GPS定位
- 获取SQL Server数据库里表占用容量大小
- [POJ]
- C++学习总结
- SpringBoot入门系列:第一篇 Hello World
- 怎样健康喝水 这样喝水有助我们的健康
- gson日期转换bean Data
- 一个表中一次性分类返回满足不同条件的数据
- Codeforces484A (strings,bitmasks)