123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TestPos : MonoBehaviour
- {
- [HideInInspector]
- public Vector3 startPos = Vector3.zero;
- public LineRenderer line1;
- public LineRenderer line3;
- public Text text;
- public LodingPanelManager showObj;
- float times = 0;
- bool state = true;
-
- /// <summary>
- /// 根据Gps值的变化移动物体
- /// </summary>
- /// <param name="Pos"></param>
- public void ObjectMove(Vector3 Pos)
- {
- // text.text = startPos.ToString();
- //text.text = " TestPos One";
- if (startPos.x == 0 || startPos.z == 0)
- return;
- //if (state)
- //{
- // state = false;
- // transform.position = new Vector3(0, -0.08f, 0);
- //}
- if (times < 0.1f)
- return;
- else
- times = 0;
- if (Mathf.Abs(transform.position.x) > 10000 || Mathf.Abs(transform.position.y) > 10000)
- transform.position = new Vector3(0, -0.08f, 0);
- Vector3 newPos = new Vector3(Pos.z - startPos.z, 0, startPos.x - Pos.x);
- text.text = newPos.x.ToString() + " , 0 , " + newPos.z.ToString();
-
- transform.position -= newPos;
- //transform.position += new Vector3(0.01f, 0, 0);
- // text.text = newPos.ToString();
- startPos = Pos;
- // transform.position += Pos;
-
- }
- private void Update()
- {
- times += Time.deltaTime;
- //if(showObj.state)
- //{
- // showObj.times += Time.deltaTime;
- // if(showObj.times>3f)
- // {
-
- // showObj.state = false;
- // showObj.ShowGameObj();
- // }
- //}
- // transform.position += new Vector3(0.02f, 0, 0);
- ShowLine();
- }
- private void LateUpdate()
- {
-
- }
- void ShowLine()
- {
- line1.gameObject.SetActive(true);
- line3.gameObject.SetActive(true);
- Debug.Log(123);
- line1.SetPosition(0, new Vector3(transform.position.x - 10, -1, transform.position.z));
- line1.SetPosition(1, new Vector3(transform.position.x + 10, -1, transform.position.z));
- //line2.SetPosition(0).transform.position + new Vector3(0, -20, 0));
- //line2.SetPosition(1).transform.position + new Vector3(0, 20, 0));
- line3.SetPosition(0, new Vector3(transform.position.x, -1, transform.position.z - 10));
- line3.SetPosition(1, new Vector3(transform.position.x, -1, transform.position.z + 10));
- //line3.SetPosition(0, transform.position + new Vector3(0, 0, -10));
- //line3.SetPosition(1, transform.position + new Vector3(0, 0, 10));
- }
- }
|