123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System.Collections;
- using System.Collections.Generic;
- using Blue;
- using UnityEngine;
- using UnityEngine.UI;
- public class GongShi2 : MonoBehaviour
- {
- public static float ff = 0;
- public static Vector3 vp3;
- public static Vector3 ve3;
- public static void F2Dto3D(float x2, float y2, float th,float tw, float x22, float y22,float sceneLength, float sceneWidth)
- {
- GameManager.Instance.StartCoroutine(startjisuan(x2,y2,th,tw,x22,y22, sceneLength, sceneWidth));
- }
- public static GameObject WebPosObj;
- public static GameObject WebPosObj2;
- static IEnumerator startjisuan(float x2, float y2, float th, float tw, float x22, float y22, float sceneLength, float sceneWidth)
- {
- Debug.Log("startjisuanstartjisuanstartjisuanstartjisuan");
- Transform parent = (SceneIOCContainer.Instance.Pull("mesh_test") as GameObject).transform;
- parent.transform.localPosition = Vector3.zero;
- parent.transform.localEulerAngles = Vector3.zero;
- if (WebPosObj == null)
- WebPosObj = new GameObject();
- if (WebPosObj2 == null)
- WebPosObj2 = new GameObject();
- WebPosObj.name = "WebPosObj";
- WebPosObj2.name = "WebPosObj2";
- WebPosObj.transform.position = Vector3.zero;
- WebPosObj.transform.eulerAngles = Vector3.zero;
- WebPosObj2.transform.position = Vector3.zero;
- WebPosObj2.transform.eulerAngles = Vector3.zero;
- // Transform meshTestParent =(SceneIOCContainer.Instance.Pull("ARSpaceForAll") as GameObject).transform;
- //创建空锚点GameObject
- GameObject go = WebPosObj;
- go.transform.parent = parent.parent;
- Vector2 p1 = new Vector2(x2 / tw * sceneLength, (th - (y2)) / th * sceneWidth);
- Vector2 p2 = Vector2.zero - p1;
- Vector3 newPosition = new Vector3(p2.x, 0, p2.y);
- parent.localPosition = newPosition;
- yield return new WaitForSeconds(0.1f);
- go.transform.localPosition = Vector3.zero;
- parent.parent = go.transform;
- yield return new WaitForSeconds(0.1f);
- //创建空锚点 朝向
- p1 = new Vector2(x22 / tw * sceneLength, (th - (y22)) / th * sceneWidth);
- p2 = Vector2.zero - p1;
- newPosition = new Vector3(-p2.x, 0, -p2.y);
- GameObject go2 = WebPosObj2;
- GameObject go3 = new GameObject();
- go2.transform.parent = parent;
- go3.transform.parent = parent;
- go3.transform.localPosition = newPosition;
- go2.transform.localPosition = newPosition;
- yield return new WaitForSeconds(0.1f);
- go2.transform.parent = go.transform.parent;
- yield return new WaitForSeconds(0.1f);
- // go.transform.parent = parent.parent;
- // yield return new WaitForSeconds(0.1f);
- //把当前物体设置到锚点内
- // yield return new WaitForSeconds(0.1f);
- go.transform.LookAt(go2.transform);
- go.transform.localEulerAngles = new Vector3(0, 360-go.transform.localEulerAngles.y, 0);
- yield return new WaitForSeconds(0.1f);
- //设置回来
- parent.parent = go.transform.parent;
- yield return new WaitForSeconds(0.1f);
- // Destroy(go);
- // Destroy(go2);
- Destroy(WebPosObj2);
- WebPosObj2= go3;
- WebPosObj.transform.parent = parent.parent;
- WebPosObj2.transform.parent = parent.parent;
- CommandSystem.Instance.Send(new InitSuccessCommand());
- }
- public static List<Vector2> GetWebPos(float th, float tw, float sceneLength, float sceneWidth)
- {
- Transform parent = (SceneIOCContainer.Instance.Pull("mesh_test") as GameObject).transform;
- WebPosObj.transform.parent = parent;
- WebPosObj2.transform.parent = parent;
- List<Vector2> lvlist = new List<Vector2>();
- Vector2 p1 = new Vector2(WebPosObj.transform.localPosition.x / sceneLength * tw , th-((WebPosObj.transform.localPosition.z) / sceneWidth * th ));
- lvlist.Add(p1);
- Vector2 p2 = new Vector2(WebPosObj2.transform.localPosition.x / sceneLength * tw , th-((WebPosObj2.transform.localPosition.z )/ sceneWidth * th ));
- lvlist.Add(p2);
- Debug.Log("Web端Pos :" + p1);
- Debug.Log("Web端Pos 2 :" + p2);
- WebPosObj.transform.parent = parent.parent;
- WebPosObj2.transform.parent = parent.parent;
- return lvlist;
- }
- }
- public struct InitEvent:IEvent
- {
- }
- public struct InitSuccessCommand : ICommand
- {
- public void OnExcute()
- {
- this.SendEvent<InitEvent>();
- }
- }
|