|
@@ -0,0 +1,88 @@
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+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)
|
|
|
+ {
|
|
|
+ Transform parent = (SceneIOCContainer.Instance.Pull("mesh_test") as GameObject).transform;
|
|
|
+
|
|
|
+ parent.transform.localPosition = Vector3.zero;
|
|
|
+ parent.transform.eulerAngles = Vector3.zero;
|
|
|
+
|
|
|
+ if (WebPosObj == null)
|
|
|
+ WebPosObj = new GameObject();
|
|
|
+
|
|
|
+ if (WebPosObj2 == null)
|
|
|
+ WebPosObj2 = new 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;
|
|
|
+ go2.transform.parent = parent;
|
|
|
+ go2.transform.localPosition = newPosition;
|
|
|
+ yield return new WaitForSeconds(0.1f);
|
|
|
+ go2.transform.parent = go.transform.parent;
|
|
|
+ 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);
|
|
|
+
|
|
|
+
|
|
|
+ WebPosObj.transform.parent = parent;
|
|
|
+ WebPosObj2.transform.parent = parent;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static List<Vector2> GetWebPos(float th, float tw, float sceneLength, float sceneWidth)
|
|
|
+ {
|
|
|
+ Transform parent = (SceneIOCContainer.Instance.Pull("mesh_test") as GameObject).transform;
|
|
|
+
|
|
|
+
|
|
|
+ List<Vector2> lvlist = new List<Vector2>();
|
|
|
+ Vector2 p1 = new Vector2(Mathf.Abs(WebPosObj.transform.localPosition.x / sceneLength * tw ), Mathf.Abs(th-((WebPosObj.transform.localPosition.z) / sceneWidth * th )));
|
|
|
+ lvlist.Add(p1);
|
|
|
+ Vector2 p2 = new Vector2(Mathf.Abs(WebPosObj2.transform.localPosition.x / sceneLength * tw ), Mathf.Abs(th-((WebPosObj2.transform.localPosition.z )/ sceneWidth * th )));
|
|
|
+ lvlist.Add(p2);
|
|
|
+ Debug.Log("Web端Pos :" + p1);
|
|
|
+ Debug.Log("Web端Pos 2 :" + p2);
|
|
|
+ return lvlist;
|
|
|
+ }
|
|
|
+}
|