using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; public class ConstructWindow : MonoBehaviour { static GameObject mtc; static GameObject mbc; static GameObject mrc; static GameObject mlc; static Color colf; static Color colm; static string colfs; static string colms; static string colfsOver; static string colmsOver; //static float os = 1f; static int ADN; public static void AddWindow(int nO) { ADN = nO; string[] C = _G.OBJs[nO]; string Name = C[0]; float w = DOIT.ConvertStringToNumber(C[6]); float h = DOIT.ConvertStringToNumber(C[7]); float d = DOIT.ConvertStringToNumber(C[8]); float px = DOIT.ConvertStringToNumber(C[15]); float py = DOIT.ConvertStringToNumber(C[16]); float pz = DOIT.ConvertStringToNumber(C[17]); float rx = DOIT.ConvertStringToNumber(C[18]); float ry = DOIT.ConvertStringToNumber(C[19]); float rz = DOIT.ConvertStringToNumber(C[20]); float wt = w; float wb = w; float MenoPos = d - 2; Vector3 CenterBotton = new(0, -h * 0.5f, 0); Vector3 CenterTop = new(0, h * 0.5f, 0); Vector3 PositionPoint; Vector3 WindowLeftBottom = new(-w * 0.5f, -h * 0.5f, 0); Vector3 WindowRightBottom = new(w * 0.5f, -h * 0.5f, 0); Vector3 WindowLeftTop = new(-w * 0.5f, h * 0.5f, 0); Vector3 WindowRightTop = new(w * 0.5f, h * 0.5f, 0); //If Molding add 4inch on w and h float molwide = 0; float molheight = 0; if (C[61] != "mx"){ molwide = 4; molheight = 4; w -= 4;h -= 4; } //Vector3 P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13; List AllPoints = new(); //_G.SC[5] = C[61]; string model = C[1]; //float ff = DOIT.ConvertStringToNumber(C[21]); //py = -_G.HEIGHT / 2 + ff + h / 2; colfs = C[62]; colfsOver = colfs; if (colfs == "wood1") colfsOver = "EAEAEA"; if (colfs == "wood2") colfsOver = "CBADAD"; colf = DOIT.CSc(colfsOver, 255); //color colms = C[63]; //print("C[63]====="+C[63]); colmsOver = colms; if (string.IsNullOrEmpty(colmsOver)) { colmsOver = "#333333"; } if (colms == "wood1") { colmsOver = "EAEAEA"; } if (colms == "wood2") { colmsOver = "CBADAD"; } colm = DOIT.CSc(colmsOver, 255); //color //create BASE GameObject BASE = GameObject.CreatePrimitive(PrimitiveType.Cube); BASE.transform.localScale = new Vector3(w +molwide+ 0.5f, h+molheight + 0.5f, d + 1f); BASE.name = Name; string Group = "Rectangle"; if (new List { "113", "115" }.Contains(model[4..])) Group = "TriangleLeft"; if (new List { "114", "116" }.Contains(model[4..])) Group = "TriangleRight"; if (new List { "117", "118", "119" }.Contains(model[4..])) Group = "Triangle"; if (new List { "120", "121", "122" }.Contains(model[4..])) Group = "Arc"; float LX = -w * 0.5f; float RX = w * 0.5f; float T = h * 0.5f; float B = -h * 0.5f; CREATE.Point(BASE, "PBLB", -w * 0.5f, -h * 0.5f, 0f);//P1 Bcck Left Bottom CREATE.Point(BASE, "PBRB", w * 0.5f, -h * 0.5f, 0f);//P2 Bcck Right Bottom CREATE.Point(BASE, "PBLU", -w * 0.5f, h * 0.5f, 0f);//P1 Back Left Upper CREATE.Point(BASE, "PBRU", w * 0.5f, h * 0.5f, 0f);//P2 Bcck Right Upper CREATE.Point(BASE, "PFRB", RX, B, 0f);//P4 Front Right upper CREATE.Point(BASE, "PFLB", LX, B, 0f);//P3 Front Left Bottom CREATE.Point(BASE, "PFLU", LX, T, 0f);//P3 Front Left upper CREATE.Point(BASE, "PFRU", RX, T, 0f);//P4 Front Right upper if (Group == "Rectangle") { CREATE.Point(BASE, "P1", RX, B, 0f);//P4 Front Right upper CREATE.Point(BASE, "P2", LX, B, 0f);//P3 Front Left Bottom CREATE.Point(BASE, "P3", LX, T, 0f);//P3 Front Left upper CREATE.Point(BASE, "P4", RX, T, 0f);//P4 Front Right upper } if (Group == "TriangleRight") { CREATE.Point(BASE, "P1", LX, B, 0f); CREATE.Point(BASE, "P2", LX, T, 0f); CREATE.Point(BASE, "P3", LX + 0.5f, T, 0f); CREATE.Point(BASE, "P4", RX, B + 0.5f, 0f); CREATE.Point(BASE, "P5", RX, B, 0f); } if (Group == "TriangleLeft") { CREATE.Point(BASE, "P1", RX, B, 0f); CREATE.Point(BASE, "P2", LX, B, 0f); CREATE.Point(BASE, "P3", LX, B + 0.5f, 0f); CREATE.Point(BASE, "P4", RX - 0.5f, T, 0f); CREATE.Point(BASE, "P3", RX, T, 0f); } if (Group == "Triangle") { CREATE.Point(BASE, "P1", RX, B, 0f); CREATE.Point(BASE, "P2", LX, B, 0f); CREATE.Point(BASE, "P3", LX, B + 0.55f, 0f); CREATE.Point(BASE, "P4", 0f, T, 0f); CREATE.Point(BASE, "P5", RX, B + 0.25f, 0f); } if (Group == "Arc") { CREATE.Point(BASE, "P1", RX, B, 0f); AllPoints.Add(new(RX, B, 0)); CREATE.Point(BASE, "P2", LX, B, 0f); AllPoints.Add(new(LX, B, 0)); Vector3 NextPoint; Vector3 Origine = new(0, B, 0); Vector3 Direcion = new(-1, 0, 0); float RadiantLenght = w * 0.5f; for (int i = 2; i < 13; i++) { Quaternion rotation = Quaternion.Euler(0, 0, -13.85f); Direcion = rotation * Direcion; NextPoint = Origine + RadiantLenght * Direcion; CREATE.Point(BASE, "P" + i.ToString(), NextPoint.x, NextPoint.y, 0f); AllPoints.Add(NextPoint); } } //Create Frame GameObject FRAME = new("frame"); FRAME.transform.parent = BASE.transform; //Create Moding GameObject MOLDING = new("Molding"); MOLDING.transform.parent = BASE.transform; float FramePos = d * 0.5f + 0.1f; float InnerPos = d - 2f; if (Group == "Rectangle") { //create frame CreateMcx(FRAME, "ft", w, 0.75f, d, 0, h / 2 - 0.75f / 2, FramePos, 0);//string n, float sx, float sy, float sz, float px, float py, float pz) CreateMcx(FRAME, "fb", w, 0.75f, d, 0, -h / 2 + 0.75f / 2, FramePos, 0); CreateMcx(FRAME, "fr", 0.75f, h - 1.5f, d, w / 2 - 0.75f / 2, 0, FramePos, 0); CreateMcx(FRAME, "fl", 0.75f, h - 1.5f, d, -w / 2 + 0.75f / 2, 0, FramePos, 0); //create inner CreateMcx(FRAME, "it", w - 1.5f, 2.0f, 2.0f, 0, h / 2 - 0.75f - 1, InnerPos, 0); CreateMcx(FRAME, "ib", w - 1.5f, 2.0f, 2.0f, 0, -h / 2 + 0.75f + 1, InnerPos, 0); CreateMcx(FRAME, "ir", 2, h - 5.5f, 2.0f, w / 2 - 0.75f - 1, 0, InnerPos, 0); CreateMcx(FRAME, "il", 2, h - 5.5f, 2.0f, -w / 2 + 0.75f + 1, 0, InnerPos, 0); } if (Group == "TriangleLeft") { //create frame CreateMcx(FRAME, "fb", w, 0.75f, d, 0, -h / 2 + 0.75f / 2, FramePos, 0); CreateMcx(FRAME, "fr", 0.75f, h - 1.5f, d, w / 2 - 0.75f / 2, 0, FramePos, 0); Vector3 Top = new(w * 0.5f, h * 0.5f, 0); Vector3 LeftBottom = new(-w * 0.5f, -h * 0.5f, 0); float Lenght = Vector3.Distance(Top, LeftBottom); Vector3 Postion = Vector3.Lerp(Top, LeftBottom, 0.5f); float Angle = Mathf.Atan2(Top.y, Top.x) * Mathf.Rad2Deg; CreateMcx(FRAME, "fl", Lenght, 0.75f, d, Postion.x, Postion.y, FramePos, Angle); //create inner // CreateMcx(FRAME, "it", w - 1.5f, 2.0f, 2.0f, 0, h / 2 - 0.75f - 1, InnerPos,0); CreateMcx(FRAME, "ib", w - 1.5f, 2.0f, 2.0f, 0, -h / 2 + 0.75f + 1, InnerPos, 0); CreateMcx(FRAME, "ir", 2, h - 1, 2.0f, w / 2 - 0.75f - 1, 0, InnerPos, 0); CreateMcx(FRAME, "il", Lenght, 2, 2.0f, Postion.x + 1, Postion.y - 1, InnerPos, Angle); } if (Group == "TriangleRight") { //create frame CreateMcx(FRAME, "fb", w, 0.75f, d, 0, -h / 2 + 0.75f / 2, FramePos, 0); CreateMcx(FRAME, "fl", 0.75f, h - 1.5f, d, -w / 2 + 0.75f / 2, 0, FramePos, 0); Vector3 Top = new(-w * 0.5f, h * 0.5f, 0); Vector3 RightBottom = new(w * 0.5f, -h * 0.5f, 0); float Lenght = Vector3.Distance(Top, RightBottom); Vector3 Postion = Vector3.Lerp(Top, RightBottom, 0.5f); float Angle = Mathf.Atan2(Top.y, Top.x) * Mathf.Rad2Deg; CreateMcx(FRAME, "fr", Lenght, 0.75f, d, Postion.x, Postion.y, FramePos, Angle); //create inner // CreateMcx(FRAME, "it", w - 1.5f, 2.0f, 2.0f, 0, h / 2 - 0.75f - 1, InnerPos,0); CreateMcx(FRAME, "ib", w - 1.5f, 2.0f, 2.0f, 0, -h / 2 + 0.75f + 1, InnerPos, 0); CreateMcx(FRAME, "il", 2, h - 5.5f, 2.0f, -w / 2 + 0.75f - +1, 0, InnerPos, 0); CreateMcx(FRAME, "ir", Lenght, 2, 2.0f, Postion.x - 1, Postion.y - 1, InnerPos, Angle); } if (Group == "Triangle") { //create frame CreateMcx(FRAME, "fb", w, 0.75f, d, 0, -h / 2 + 0.75f / 2, FramePos, 0); //Left Vector3 Top = new(0, h * 0.5f, 0); Vector3 LeftBottom = new(-w * 0.5f, -h * 0.5f, 0); Vector3 RightBottom = new(w * 0.5f, -h * 0.5f, 0); float Lenght = Vector3.Distance(Top, RightBottom); float Angle = Mathf.Atan2(h, RightBottom.x) * Mathf.Rad2Deg; Vector3 PostionL = Vector3.Lerp(Top, LeftBottom, 0.5f); Vector3 PostionR = Vector3.Lerp(Top, RightBottom, 0.5f); CreateMcx(FRAME, "fl", Lenght, 0.75f, d, PostionL.x, PostionL.y, FramePos, Angle); CreateMcx(FRAME, "fr", Lenght, 0.75f, d, PostionR.x, PostionR.y, FramePos, -Angle); //create inner // CreateMcx(FRAME, "it", w - 1.5f, 2.0f, 2.0f, 0, h / 2 - 0.75f - 1, InnerPos,0); CreateMcx(FRAME, "ib", w - 1.5f, 2.0f, 2.0f, 0, -h / 2 + 0.75f + 1, InnerPos, 0); CreateMcx(FRAME, "il", Lenght, 2, 2.0f, PostionL.x + 1, PostionL.y - 1, InnerPos, Angle); CreateMcx(FRAME, "ir", Lenght, 2, 2.0f, PostionR.x - 1, PostionR.y - 1, InnerPos, -Angle); } if (Group == "Arc") { for (int i = 0; i < AllPoints.Count; i++) { int Nextpoint = i + 1; if (i == AllPoints.Count - 1) { Nextpoint = 0; } CreateFrame(FRAME, AllPoints[i], AllPoints[Nextpoint], 1.5f, d, FramePos + 0.1f); CreateFrame(FRAME, AllPoints[i], AllPoints[Nextpoint], 4f, 2, InnerPos); } } //create molding float MoldingPos = -0.5f; float CoverPos = -1.1f; if (string.IsNullOrEmpty(C[61])) { C[61] = "mx"; } if (C[61] != "mx") { float mow = 3; CreateMcx(MOLDING, "xt", w + 2 * mow - 2, mow, 1.0f, 0, h / 2 + mow / 2 - 1f, MoldingPos, 0); CreateMcx(MOLDING, "xb", w + 2 * mow - 2, mow, 1.0f, 0, -h / 2 - mow / 2 + 1f, MoldingPos, 0); CreateMcx(MOLDING, "xr", mow, h - 2, 1.0f, w / 2 + mow / 2 - 1, 0, MoldingPos, 0); CreateMcx(MOLDING, "xl", mow, h - 2, 1.0f, -w / 2 - mow / 2 + 1, 0, MoldingPos, 0); float l = w - 2 + mow * 2; //mtc = new GameObject("ct"); mtc = CreateMcxCover("xct", -l / 2, mow / 2, l / 2, mow / 2, l / 2 - mow, -mow / 2, -l / 2 + mow, -mow / 2); mtc.transform.position = new Vector3(0, h / 2 - 1 + mow / 2, CoverPos); mtc.transform.SetParent(MOLDING.transform); mbc = CreateMcxCover("xcb", -l / 2 + mow, mow / 2, l / 2 - mow, mow / 2, l / 2, -mow / 2, -l / 2, -mow / 2); mbc.transform.position = new Vector3(0, -h / 2 + 1 - mow / 2, CoverPos); mbc.transform.SetParent(MOLDING.transform); l = h - 2 + mow * 2; mrc = CreateMcxCover("xcr", -l / 2, mow / 2, l / 2, mow / 2, l / 2 - mow, -mow / 2, -l / 2 + mow, -mow / 2); mrc.transform.position = new Vector3(w / 2 - 1 + mow / 2, 0, CoverPos); mrc.transform.localRotation = Quaternion.Euler(0, 0, -90); mrc.transform.SetParent(MOLDING.transform); mlc = CreateMcxCover("xcl", -l / 2, mow / 2, l / 2, mow / 2, l / 2 - mow, -mow / 2, -l / 2 + mow, -mow / 2); mlc.transform.position = new Vector3(-w / 2 + 1 - mow / 2, 0, CoverPos); mlc.transform.localRotation = Quaternion.Euler(0, 0, 90); mlc.transform.SetParent(MOLDING.transform); } //create Back Ground if (!_G.PHOTO) { GameObject bg = GameObject.CreatePrimitive(PrimitiveType.Quad); bg.name = "background"; bg.transform.localScale = new Vector3(w + 6, h + 6, 1); bg.transform.position = new Vector3(0, 0, InnerPos + 3); bg.transform.localRotation = Quaternion.Euler(0, 0, 0); bg.GetComponent().material = _G.BGPATIO; bg.GetComponent().probeAnchor = GameObject.Find("Reflection Probe ext").transform; //bg.GetComponent().material.SetFloat("_Metallic", 0.9F); //bg.GetComponent().material.SetFloat("_Smoothness", 1.0F); bg.GetComponent().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; bg.transform.SetParent(BASE.transform); } //create meno float mw = 0.5f; if (model == "WIND102") { CreateMcx(FRAME, "x1", w - 5.5f, 2.0f, 2.0f, 0, 0, MenoPos, 0); } if (model == "WIND103") { CreateMcx(FRAME, "x1", w - 5.5f, 2.0f, 2.0f, 0, h / 6, MenoPos, 0); CreateMcx(FRAME, "x2", w - 5.5f, 2.0f, 2.0f, 0, -h / 6, MenoPos, 0); } if (model == "WIND104") { CreateMcx(FRAME, "x1", 2, h - 5.5f, 2.0f, 0, 0, MenoPos, 0); } if (model == "WIND105") { CreateMcx(FRAME, "x1", 2, h - 5.5f, 2.0f, -w / 6, 0, MenoPos, 0); CreateMcx(FRAME, "x2", 2, h - 5.5f, 2.0f, w / 6, 0, MenoPos, 0); } if (model == "WIND106") { CreateMcx(FRAME, "x1", 1, h - 5.5f, mw, 0, 0, MenoPos, 0); CreateMcx(FRAME, "x2", w - 5.5f, mw, mw, 0, h / 6, MenoPos, 0); CreateMcx(FRAME, "x3", w - 5.5f, mw, mw, 0, -h / 6, MenoPos, 0); } if (model == "WIND107") { CreateMcx(FRAME, "x1", mw, h - 5.5f, mw, -w / 6, 0, MenoPos, 0); CreateMcx(FRAME, "x2", mw, h - 5.5f, mw, w / 6, 0, MenoPos, 0); CreateMcx(FRAME, "x3", w - 5.5f, mw, mw, 0, h / 6, MenoPos, 0); CreateMcx(FRAME, "x4", w - 5.5f, mw, mw, 0, -h / 6, MenoPos, 0); } if (model == "WIND108") { CreateMcx(FRAME, "x1", mw, (h - 5.5f) / 2, mw, -w / 6, (h - 5.5f) / 4, MenoPos, 0); CreateMcx(FRAME, "x2", mw, (h - 5.5f) / 2, mw, w / 6, (h - 5.5f) / 4, MenoPos, 0); CreateMcx(FRAME, "x3", w - 5.5f, mw, mw, 0, (h - 5.5f) / 4, MenoPos, 0); CreateMcx(FRAME, "x4", w - 5.5f, 2.0f, 2.0f, 0, 0, MenoPos, 0); } if (model == "WIND109") { CreateMcx(FRAME, "x1", mw, (h - 5.5f), mw, -w / 6, 0, MenoPos, 0); CreateMcx(FRAME, "x2", mw, (h - 5.5f), mw, w / 6, 0, MenoPos, 0); CreateMcx(FRAME, "x3", w - 5.5f, 1.0f, mw, 0, (h - 5.5f) / 4, MenoPos, 0); CreateMcx(FRAME, "x4", w - 5.5f, 2.0f, 2.0f, 0, 0, MenoPos, 0); CreateMcx(FRAME, "x5", w - 5.5f, mw, mw, 0, -(h - 5.5f) / 4, MenoPos, 0); } if (model == "WIND110") { CreateMcx(FRAME, "x1", mw, (h - 5.5f), mw, -w / 4, 0, MenoPos, 0); CreateMcx(FRAME, "x2", 2, (h - 5.5f), 2.0f, 0, 0, MenoPos, 0); CreateMcx(FRAME, "x3", mw, (h - 5.5f), mw, w / 4, 0, MenoPos, 0); CreateMcx(FRAME, "x4", w - 5.5f, 0.5f, mw, 0, (h - 5.5f) / 4, MenoPos, 0); CreateMcx(FRAME, "x5", w - 5.5f, mw, mw, 0, 0, MenoPos, 0); CreateMcx(FRAME, "x6", w - 5.5f, mw, mw, 0, -(h - 5.5f) / 4, MenoPos, 0); } if (model == "WIND111") { float hh = h / 2 - 5.5f / 2 - 8; CreateMcx(FRAME, "x1", mw, 8, mw, -w / 6, hh + 4, MenoPos, 0); CreateMcx(FRAME, "x2", mw, 8, mw, w / 6, hh + 4, MenoPos, 0); CreateMcx(FRAME, "x3", w - 5.5f, 0.5f, 0.5f, 0, hh, MenoPos, 0); } if (model == "WIND112") { float ww = -w / 2 + 5.5f / 2 + 4; float hh = h / 2 - 5.5f / 2 - 4; CreateMcx(FRAME, "x1", mw, h - 5.5f, mw, -ww, 0, MenoPos, 0); CreateMcx(FRAME, "x2", mw, h - 5.5f, mw, ww, 0, MenoPos, 0); CreateMcx(FRAME, "x3", w - 5.5f, mw, mw, 0, hh, MenoPos, 0); CreateMcx(FRAME, "x4", w - 5.5f, mw, mw, 0, -hh, MenoPos, 0); } if (model == "WIND115") { PositionPoint = Vector3.Lerp(WindowRightTop, WindowLeftBottom, 0.5f); CreateMeno(FRAME, WindowRightBottom, PositionPoint, 0.5f, 0.5f, MenoPos); } if (model == "WIND116") { PositionPoint = Vector3.Lerp(WindowLeftTop, WindowRightBottom, 0.5f); CreateMeno(FRAME, WindowLeftBottom, PositionPoint, 0.5f, 0.5f, MenoPos); } if (model == "WIND118") { CreateMcx(FRAME, "x1", 1, h - 5.5f, 0.5f, 0, 0, MenoPos, 0); } if (model == "WIND119") { CreateMcx(FRAME, "x1", 0.5f, h - 5.5f, 0.5f, 0, 0, MenoPos, 0); PositionPoint = Vector3.Lerp(CenterTop, WindowLeftBottom, 0.5f); CreateMeno(FRAME, CenterBotton, PositionPoint, 0.5f, 0.5f, MenoPos); PositionPoint = Vector3.Lerp(CenterTop, WindowRightBottom, 0.5f); CreateMeno(FRAME, CenterBotton, PositionPoint, 0.5f, 0.5f, MenoPos); } if (model == "WIND121") { CreateMcx(FRAME, "x1", 1, h - 5.5f, 0.5f, 0, 0, MenoPos, 0); } if (model == "WIND122") { CreateMcx(FRAME, "x1", 0.5f, h - 5.5f, 0.5f, 0, 0, MenoPos, 0); CreateMeno(FRAME, CenterBotton, AllPoints[3], 0.5f, 0.5f, MenoPos); CreateMeno(FRAME, CenterBotton, AllPoints[10], 0.5f, 0.5f, MenoPos); } AddGlass(BASE, new Vector3(w - 1, h - 1, 0.25f), new Vector3(0, 0, InnerPos)); //SPLASH print("C[55=====" + C[55]); print("C[55====2=" + C[45]); DOBS.SplashARROWN(BASE, C[55], w, h, d - 2.25f, C[54], 0); Mesure.Addpoints("WALL", BASE); //Stet in scene BASE.transform.position = new Vector3(px, py, pz); BASE.transform.localRotation = Quaternion.Euler(rx, ry, rz); BASE.AddComponent(typeof(MoveObject)); BASE.GetComponent().material = _G.INV;// Resources.Load("MATERIALS/INVISIBLE") as Material; BASE.transform.SetParent(GameObject.Find("SCENE").transform); //AI if (_AI.On && !AiStep.BoolTitle("Genarate Ai")) { AiButton.Instance.GetTitle().text = AiText.Trans("Windows Position"); AiButton.Instance.GetPlus().SetActive(true); } } static void CreateMcx(GameObject O, string n, float sx, float sy, float sz, float px, float py, float pz ,float RotationZ ) { GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.GetComponent().enabled = false; obj.transform.localScale = new Vector3(sx, sy, sz); obj.transform.position = new Vector3(px, py, pz); obj.transform.eulerAngles=new(0,0,RotationZ); //Color Frame string colorFrame=_G.OBJs[ADN][62]; if(colorFrame.Split('_').Length==1){colorFrame+="_Semi";} Material Mat=Instantiate(UIT_MATERIAL.GetMaterial(colorFrame)); obj.GetComponent().material = Mat;//new Material(Shader.Find("Diffuse")); obj.GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; if (colfs[4..] == "wood") { obj.GetComponent().material.SetTexture("_Texture",Resources.Load("Molding/m101w") as Texture2D); } //if (colfs == "wood2") { obj.GetComponent().material.color = colm; } if (n == "mt" || n == "mb" || n == "mr" || n == "ml") { obj.GetComponent().material.color = colm; } obj.name = n; obj.transform.SetParent(O.transform); obj.GetComponent().enabled = false; if (O.name == "Molding") obj.tag = "framemolding"; else obj.tag = "frame"; } static GameObject CreateMcxCover(string n, float P1x, float P1y, float P2x, float P2y, float P3x, float P3y, float P4x, float P4y) { GameObject obj = new("TopCover"); obj.AddComponent(typeof(MeshFilter)); obj.AddComponent(typeof(MeshRenderer)); obj.GetComponent().mesh = CreateMesh(P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y); obj.transform.position = new Vector3(0, 0, -5.1f); //Color Cover string colorCover=_G.OBJs[ADN][63]; //print("_G.OBJs[ADN][63]===="+_G.OBJs[ADN][63]); if(colorCover.Split('_').Length==1){colorCover+="_Semi";} Material Mat=Instantiate(UIT_MATERIAL.GetMaterial(colorCover)); obj.GetComponent().material = Mat;//new Material(Shader.Find("Diffuse")); Mat.SetColor("_c2",Color.grey); obj.name = n; Mat.SetTexture("_Texture",Resources.Load("Molding/" + _G.OBJs[ADN][61]) as Texture2D); if (colfs[4..] == "wood") { Mat.SetTexture("_Texture",Resources.Load("Molding/" + _G.OBJs[ADN][61] + "w") as Texture2D);} obj.tag = "framemolding"; return obj; } static Mesh CreateMesh(float P1x, float P1y, float P2x, float P2y, float P3x, float P3y, float P4x, float P4y) { Mesh m = new() { name = "ScriptedMesh", vertices = new Vector3[] { new (P1x, P1y, 0.01f), new (P2x, P2y, 0.01f), new (P3x, P3y, 0.01f), new (P4x, P4y, 0.01f) }, uv = new Vector2[] { new (0, 1), new (1, 1), new (1, 0), new (0, 0) }, triangles = new int[] { 0, 1, 2, 0, 2, 3 } }; m.RecalculateNormals(); return m; } static void CreateMeno(GameObject O,Vector3 p1,Vector3 p2,float w, float d,float MenoPos){ float Length= Vector3.Distance(p1,p2); float Angle = Mathf.Atan2(p1.y, p2.x) * Mathf.Rad2Deg; Vector3 PositionCenter=Vector3.Lerp(p1,p2,0.5f); CreateMcx(O, "Meno", Length, w, d, PositionCenter.x, PositionCenter.y, MenoPos,-Angle); } static void CreateFrame(GameObject O, Vector3 p1,Vector3 p2,float w, float d,float MenoPos){ float Length= Vector3.Distance(p1,p2); Vector3 PositionCenter=Vector3.Lerp(p1,p2,0.5f); float angle = Mathf.Rad2Deg * Mathf.Atan2(p2.y -p1.y, p2.x - p1.x); CreateMcx(O, "Meno", Length, w, d, PositionCenter.x, PositionCenter.y, MenoPos,angle); } public static void AddGlass(GameObject BASE,Vector3 Size,Vector3 Position){ //Glass GameObject Glass = GameObject.CreatePrimitive(PrimitiveType.Quad); Glass.name = "glass"; Glass.transform.localScale = Size; Glass.transform.position = Position; Glass.GetComponent().material = _G.GLASS; Glass.GetComponent().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; Glass.transform.parent = BASE.transform; Glass.GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; } }