using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Globalization; public class MESURE : MonoBehaviour { public static string get(string sel, string tar) { int Sn = Get.GetObjectIndex(sel); int Tn = Get.GetObjectIndex(tar); float MES = 0; string M = "N/A"; GameObject S = GameObject.Find(sel); GameObject T = GameObject.Find(tar); float A = getR(Sn, Tn); GameObject RR = GameObject.Find("RR"); S.transform.SetParent(RR.transform); T.transform.SetParent(RR.transform); RR.transform.localRotation = Quaternion.Euler(0, A, 0); Vector3 Tv = T.GetComponent().bounds.size; Vector3 Sv = S.GetComponent().bounds.size; Vector3 PT = T.transform.position; Vector3 PS = S.transform.position; float dx = Mathf.Abs(PT.x - PS.x); float wx = Tv.x / 2 + Sv.x / 2 - 0.5f; RR.transform.localRotation = Quaternion.Euler(0, 0, 0); S.transform.SetParent(GameObject.Find("SCENE").transform); T.transform.SetParent(GameObject.Find("SCENE").transform); MES = dx - wx; M = DOIT.CNs(MES); return M; } public static float getR(int S, int T) { float A = 90; string Sa = _G.OBJs[S][19];//Rotation angle string Ta = _G.OBJs[T][19];//Rotation angle if (Sa == Ta && _G.OBJs[S][22] == _G.OBJs[T][22] && Sa == "0") { A = 0; } if (Sa == Ta && _G.OBJs[S][22] == _G.OBJs[T][22] && Sa == "90") { A = 90; } if (Sa == Ta && _G.OBJs[S][22] == _G.OBJs[T][22] && Sa == "180") { A = 0; } if (Sa == Ta && _G.OBJs[S][22] == _G.OBJs[T][22] && Sa == "270") { A = 90; } if (Sa == Ta && _G.OBJs[S][22] == _G.OBJs[T][22] && Sa == "45") { A = 45; } if (Sa == "0" && Ta == "90" && _G.OBJs[S][22] == _G.OBJs[T][22]) A = 0; if (Sa == "90" && Ta == "0" && _G.OBJs[S][22] == _G.OBJs[T][22]) A = 0; if (Sa == "90" && Ta == "270") A = 0; if (Sa == "90" && Ta == "270") A = 0; if (Sa == "270" && Ta == "90") A = 0; return A; } public static float FindXWonWall(int nO, int wn, string XW) { //set.SHRS(true); // TODO : needed? float X = 0; GameObject wall = GameObject.Find("w" + wn.ToString()); GameObject sel = GameObject.Find(_G.OBJs[nO][0]); Vector3 WR = wall.transform.localRotation.eulerAngles; sel.transform.SetParent(wall.transform); wall.transform.localRotation = Quaternion.Euler(0, 0, 0); Vector3 wP = wall.transform.position; Vector3 sP = sel.transform.position; if (XW == "X") X = sP.x - wP.x; if (XW == "W") X = sel.GetComponent().bounds.size.x - 0.5F; if (XW == "H") X = sel.GetComponent().bounds.size.y - 0.5F; if (XW == "Z") X = wP.z - sP.z; wall.transform.localRotation = Quaternion.Euler(WR.x, WR.y, WR.z); sel.transform.SetParent(GameObject.Find("SCENE").transform); return X; } public static void pixel(Vector2 V) { if (V.x > _G.pixl) _G.pixl = V.x; if (V.x < _G.pixs) _G.pixs = V.x; if (V.y > _G.piyl) _G.piyl = V.y; if (V.y < _G.piys) _G.piys = V.y; } public static void resetpixel() { _G.pixl = 0; _G.pixs = 0; _G.piyl = 0; _G.piys = 0; } // public static void setscale(float S) // { // Camera cam = GameObject.Find("MainCamera").GetComponent(); // float Iw = Mathf.Abs(_G.pixl - _G.pixs); // float Ih = Mathf.Abs(_G.piyl - _G.piys); // Vector2 Dpos = new Vector2(_G.pixs + Iw / 2, _G.piyl - Ih / 2); // Vector3 VCam = cam.transform.position; // cam.transform.position = new Vector3(Dpos.x, Dpos.y, VCam.z); // float scale = Iw / S;// // float sr = 1280f / 750f; // float sh = S / sr; // if (Ih / scale > sh) { scale = Ih / sh; } // cam.orthographicSize = scale; // //print("scale=================================================================="+scale); // _G.LS = (0.04f * scale) / 10; // if (_G.LS < 0.2f) _G.LS = 0.2f; // //print("_G.LS=================================================================="+_G.LS); // } }