123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class RtkPos : MonoBehaviour
- {
- /// <summary>
- /// 显示物体
- /// </summary>
- public List<Transform> list_Obj;
- /// <summary>
- /// 根据实地GPS数据转化位置信息 ( 与 List_Obj 对应)
- /// </summary>
- public List<Vector2> list_Pos;
- public List<Transform> list_Box;
- public Text text;
- /// <summary>
- /// 根据玩家传输进来的Gps 推算出 物体位置
- /// </summary>
- /// <param name="playerGps"></param>
- public void SettingPos( Vector2 playerGps )
- {
-
- if(list_Pos.Count!=list_Obj.Count)
- {
- Debug.LogError(" RTK版本 提供的物体和提供的坐标数量不符 ");
- return;
- }
-
- if (API_SVR.GetHead()!=null)
- for (int i = 0; i < list_Obj.Count; i++)
- {
- Vector2 diff = list_Pos[i] - playerGps;
- Vector3 playerPos = API_SVR.GetHead().position;
- Vector3 pos = new Vector3(playerPos.x + diff.x, list_Obj[i].position.y, playerPos.z + diff.y);
- list_Obj[i].position = pos;
- list_Box[i].position = pos;
- //text.text = pos.ToString();
- Debug.Log(pos);
- }
- }
-
- }
|