using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.UI.Extensions; using TMPro; using System.Globalization; public class SetCab : MonoBehaviour { public GameObject SHOW; public Image model; public InputField A; public InputField B; public InputField C; public InputField D; public InputField E; public InputField F; public InputField K; public TMP_Dropdown AD; public TMP_Dropdown BD; public TMP_Dropdown CD; public TMP_Dropdown DD; public Text FixB; public Text FixA; public Text FixC; public Text FixD; public Text FixE; public Text FixF; public Text FixK; public GameObject cb;//cieblink public Text Des; public Text Flip; static float sch = 1; static float scw = 1; static Vector2 R1 = new(0, 0); static Vector2 R2 = new(0, 0); static Vector2 R3 = new(0, 0); static Vector2 R4 = new(0, 0); static Vector2 R5 = new(0, 0); static Vector2 R6 = new(0, 0); public void Showselect() { Showselected(name); } public void Showselected(string modelname) { _G.VTcat="ST"; //print("modelname====================================================================="+modelname); Allfalse.SetCabPnlOpen(); Get.o1("SHOWSELECTION").transform.Find("DIMS").gameObject.SetActive(true); _G.SC[0] = modelname; CabinetListData c = Get.CabinetCode(modelname); Set.alpha(SHOW, true); DOIT.AllChildOff(Get.o1("DIMS")); //Model _G.RCAT = c.Cab_Image; string mod = _G.RCAT.Split('.')[0] + "." + _G.RCAT.Split('.')[1] + "." + _G.RCAT.Split('.')[2]; model.GetComponent().sprite = Resources.Load("CABIMAGE/" + mod); //Set dim if (c.A_Value.IndexOf('_') != -1) { setDIMFIX(AD, CsvHeaders.A_Value, c); } else { SetDIM(A.gameObject, CsvHeaders.A_Value, c, FixA.gameObject); } if (c.B_Value.IndexOf('_') != -1 || c.D_Value.IndexOf('_') != -1) { if (c.K_Value != "0") setDIMFIX(DD, CsvHeaders.D_Value, c); else if (c.K_Value == "0") setDIMFIX(BD, CsvHeaders.B_Value, c); } else { SetDIM(B.gameObject, CsvHeaders.B_Value, c, FixB.gameObject); SetDIM(D.gameObject, CsvHeaders.D_Value, c, FixD.gameObject); } if (c.C_Value.IndexOf('_') != -1) { setDIMFIX(CD, CsvHeaders.C_Value, c); } else { SetDIM(C.gameObject, CsvHeaders.C_Value, c, FixC.gameObject); } SetDIM(E.gameObject, CsvHeaders.E_Value, c, FixE.gameObject); SetDIM(F.gameObject, CsvHeaders.F_Value, c, FixF.gameObject); //Kick if (c.Cab_Sub_Category.IndexOf("W") != -1) { c.K_Value = "0"; } if (c.K_Value != "" && c.K_Value != "0") { if (_P.KickFix == true || checkBool("FixB") && checkBool("FixB")) { FixK.gameObject.SetActive(true); FixK.text = DOIT.CSss(c.K_Value); } else { K.gameObject.SetActive(true); K.text = DOIT.CSss(c.K_Value); } } //Description if (_G.L == 1) { Des.text = c.Unique_Name + " : " + c.Description_Language_1; } else if (_G.L == 2) { Des.text = c.Unique_Name + " : " + c.Description_Language_2; } else if (_G.L == 3) { Des.text = c.Unique_Name + " : " + c.Description_Language_3; } //Flip string flip = ""; if (c.Flip == "L") flip = TRANS.This("T_Left"); else if (c.Flip == "R") flip = TRANS.This("T_Right"); else if (c.Flip == "F") flip = TRANS.This("T_Fix"); Flip.text = flip; //set skew for (int i = 0; i < Get.o2("SHOWSELECTION", "MODEL").transform.childCount; i++) { Get.o2("SHOWSELECTION", "MODEL").transform.GetChild(i).transform.GetComponent().alpha = 0; } _G.CODEPATERN = c.Pattern_Door_1; _G.CODEPATERN2 = c.Pattern_Door_2; Paternskew(c.Cab_Image); if (_G.User == "Admin") { Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "DELETEFROMLIST").SetActive(true); Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "RE_CREATOR").SetActive(true); } string cat = Get.o1("Title").GetComponent().text; SetOPTIONS_ONOFF(cat, modelname); SetBoxSelection(); } public void SetBoxSelection(){ print(_G.UIT_LibraryBoxTextures[0]); } public void SetOPTIONS_ONOFF(string name, string modelname) { GameObject COUNTER = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/OPTIONS_ONOFF/COUNTER"); //GameObject NOLEGS = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/OPTIONS_ONOFF/NOLEGS"); //GameObject NOKICK = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/OPTIONS_ONOFF/NOKICK"); GameObject UNDERFINISH = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/OPTIONS_ONOFF/UNDERFINISH"); GameObject INTERIORFINISH = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/OPTIONS_ONOFF/INTERIORFINISH"); GameObject NO_DOOR = Get.o1("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/OPTIONS_ONOFF/NO_DOOR"); print("_P.ListSwitch[NO_DOOR]=="+_P.ListSwitch["NO_DOOR"]); if(_P.ListSwitch["NO_DOOR"])NO_DOOR.SetActive(true); else NO_DOOR.SetActive(false); COUNTER.SetActive(false); //NOLEGS.SetActive(false); //NOKICK.SetActive(false); UNDERFINISH.SetActive(false); INTERIORFINISH.SetActive(true); if (name == "BASE" || name == "CBASE") { COUNTER.SetActive(true); COUNTER.transform.GetComponent().isOn = false; } // if (name == "TALL" || name == "BASE" || name == "CBASE") // { // NOLEGS.SetActive(true); NOLEGS.transform.GetComponent().isOn = false; // NOKICK.SetActive(true); NOKICK.transform.GetComponent().isOn = false; // } if (name == "WALL" || name == "CWALL") { UNDERFINISH.SetActive(true); } //string SideFinish = Get.CabValue(modelname, 32); string SideFinish = Get.LibraryValue(modelname, CsvHeaders.Exterior_Finish_Recipe, DataTypes.Cabinet); if (SideFinish == "1_1_1_1_1_1_1") { INTERIORFINISH.transform.GetComponent().isOn = false; } else { INTERIORFINISH.transform.GetComponent().isOn = true; } if (SideFinish.Split("_")[6] == "1") { UNDERFINISH.transform.GetComponent().isOn = true; } else { UNDERFINISH.transform.GetComponent().isOn = false; } //if supended cabinet //string isSuspended = Get.CabValue(modelname, 47); string isSuspended = Get.LibraryValue(modelname, CsvHeaders.Is_Suspended, DataTypes.Cabinet); // if (isSuspended == "y") // { // NOLEGS.SetActive(true); NOLEGS.transform.GetComponent().isOn = true; // NOKICK.SetActive(true); NOKICK.transform.GetComponent().isOn = true; // } } public static void Paternskew(string name) { string[] NAME = name.Split('.'); string ns = NAME[0] + "." + NAME[1] + "." + NAME[2]; if(NAME[1]!="14" && NAME[1]!="16"){ if (ns == "M.5.L") ns = "M.5.L.A"; if (ns == "M.5.R") ns = "M.5.R.A"; if (ns == "M.8.L") ns = "M.8.L.A"; if (ns == "M.8.R") ns = "M.8.R.A"; if (ns == "M.13.L") ns = "M.13.L.A"; if (ns == "M.13.R") ns = "M.13.R.A"; string path = "CABINETpnl/SHOWSELECTION/MODEL/SkewPatern"; if (_G.PNL == "NewCAB") { path = "CABINETpnl/ADDINPUTS/MODEL/SkewPatern"; } //print("path+ns)======"+path+ns); GameObject SK = Get.o1(path + ns); SK.transform.GetComponent().alpha = 1; AddPATERN1(SK); if (NAME[1] == "5" || NAME[1] == "8" || NAME[1] == "13" ) { string ns2 = ns.Replace("A", "B"); GameObject SK2 = Get.o1(path + ns2); SK2.transform.GetComponent().alpha = 1; AddPATERN2(SK2); } } } public static Vector2 WorldToScreenPoint(Camera cam, Vector3 worldPoint) { if (cam == null) return new(worldPoint.x, worldPoint.y); return (Vector2)cam.WorldToScreenPoint(worldPoint); } public void SetDIM(GameObject O, CsvHeaders header, CabinetListData c, GameObject O2) { string currentValueHeader = header.ToString(); string letter = currentValueHeader.Split('_')[0]; string maxValueHeader = letter + "_Max"; string minValueHeader = letter + "_Min"; CsvHeaders minHeader = Define.GetHeaderByValue(minValueHeader); CsvHeaders maxHeader = Define.GetHeaderByValue(maxValueHeader); string minValue = c.GetPropertyValue(minHeader); string maxValue = c.GetPropertyValue(maxHeader); string currentValue = c.GetPropertyValue(header); if (minValue != maxValue && !string.IsNullOrEmpty(currentValue)) { O.SetActive(true); O.transform.Find("min").GetComponent().text = minValue; O.GetComponent().text = DOIT.CSss(currentValue); O.transform.Find("max").GetComponent().text = maxValue; } else if (minValue == maxValue && !string.IsNullOrEmpty(currentValue)) { O2.SetActive(true); O2.GetComponent().text = DOIT.CSss(currentValue); } } //public void setDIMFIX(TMP_Dropdown O, int ind, string[] c) //{ // O.gameObject.SetActive(true); // string[] list = c[ind].Split("_"); // TMP_Dropdown dropdown = O.GetComponent(); // dropdown.options.Clear(); // foreach (string option in list) // { // dropdown.options.Add(new TMP_Dropdown.OptionData(option)); // } // dropdown.value = 0; // dropdown.RefreshShownValue(); // if (O.name == "DropdownD") // { // FixB.gameObject.SetActive(true); // float valueD = DOIT.ConvertStringToNumber(DOIT.CSs(GameObject.Find("DropdownD").transform.Find("Label").GetComponent().text)); // float valueK = DOIT.ConvertStringToNumber(c[21]); // float value = valueD + valueK; // FixB.gameObject.GetComponent().text = value.ToString(); // } //} public void setDIMFIX(TMP_Dropdown O, CsvHeaders header, CabinetListData c) { O.gameObject.SetActive(true); string[] list = c.GetPropertyValue(header).Split("_"); TMP_Dropdown dropdown = O.GetComponent(); dropdown.options.Clear(); foreach (string option in list) { dropdown.options.Add(new TMP_Dropdown.OptionData(option)); } dropdown.value = 0; dropdown.RefreshShownValue(); if (O.name == "DropdownD") { FixB.gameObject.SetActive(true); float valueD = DOIT.ConvertStringToNumber(DOIT.CSs(GameObject.Find("DropdownD").transform.Find("Label").GetComponent().text)); float valueK = DOIT.ConvertStringToNumber(c.GetPropertyValue(CsvHeaders.K_Value)); float value = valueD + valueK; FixB.gameObject.GetComponent().text = value.ToString(); } } public void resetInput() { if (_G.VTcat != "TMP") ResetInput(name); else { ResetInputTMP(name); } } public static void ResetInput(string name) { print("------------------------RRESSIZZZZE----------------------1-------" + name); string model = Get.o2("SHOWSELECTION", "MODEL").GetComponent().sprite.name; string[] m = model.Split('.'); bool AV = checkBool("InputFieldA"); bool BV = checkBool("InputFieldB"); bool CV = checkBool("InputFieldC"); bool DV = checkBool("InputFieldD"); bool EV = checkBool("InputFieldE"); bool FV = checkBool("InputFieldF"); bool KV = checkBool("InputFieldK"); bool AF = checkBool("FixA"); bool BF = checkBool("FixB"); bool CF = checkBool("FixC"); bool DF = checkBool("FixD"); bool EF = checkBool("FixE"); bool FF = checkBool("FixF"); bool KF = checkBool("FixK"); //Min Max stop if (AV) { minmax("A"); } if (BV) { minmax("B"); } if (CV) { minmax("C"); } if (DV) { minmax("D"); } if (EV) { minmax("E"); } if (FV) { minmax("F"); } //if(KV){minmax("K");} //Base hight if (BV && DF) { if (name == "InputFieldB") { float K = Getfloat("FixK"); float B = Getfloat("InputFieldB"); addString("InputFieldD", B - K); } } if (m[1] == "4" && EV && FF || m[1] == "5" && EV && FF) { if (name == "InputFieldE") { float E = Getfloat("InputFieldE"); addString("FixF", E); } } if (m[1] == "4" && AV && FV && CV && EV || m[1] == "4" && AV && FV && CV && EV) { if (name == "InputFieldA") { float A = Getfloat("InputFieldA"); float C = Getfloat("InputFieldC"); float E = Getfloat("InputFieldE"); float F = A - (C - E); addString("InputFieldF", F); } if (name == "InputFieldC") { float A = Getfloat("InputFieldA"); float C = Getfloat("InputFieldC"); float F = Getfloat("InputFieldF"); float E = C - (A - F); addString("InputFieldE", E); } if (name == "InputFieldE") { float A = Getfloat("InputFieldA"); float C = Getfloat("InputFieldC"); float E = Getfloat("InputFieldE"); float F = A - (C - E); addString("InputFieldF", F); } if (name == "InputFieldF") { float A = Getfloat("InputFieldA"); float C = Getfloat("InputFieldC"); float F = Getfloat("InputFieldF"); float E = C - (A - F); addString("InputFieldE", E); } } if (BV && DV && KV) { if (name == "InputFieldK") { float K = Getfloat("InputFieldK"); float D = Getfloat("InputFieldD"); addString("InputFieldB", D + K); } if (name == "InputFieldB") { float K = Getfloat("InputFieldK"); float B = Getfloat("InputFieldB"); addString("InputFieldD", B - K); } if (name == "InputFieldD") { float K = Getfloat("InputFieldK"); float D = Getfloat("InputFieldD"); addString("InputFieldB", D + K); } } } public static void ResetInputTMP(string name) { print("------------------------RRESSIZZZZE TMP----------------------1-------" + name); string model = Get.o2("ADDINPUTS", "MODEL").GetComponent().sprite.name; string[] m = model.Split('.'); bool AV = checkBool("A"); bool BV = checkBool("B"); bool CV = checkBool("C"); bool DV = checkBool("D"); bool EV = checkBool("E"); bool FV = checkBool("F"); bool KV = checkBool("K"); //Base hight if (BV && DV && !KV) { if (name == "Bvalue") { float K = Getfloat("FixK"); float B = Getfloat("InputFieldB"); addString("InputFieldD", B - K); } } if (BV && DV && KV) { if (name == "InputFieldK") { float K = Getfloat("InputFieldK"); float D = Getfloat("InputFieldD"); addString("InputFieldB", D + K); } if (name == "InputFieldB") { float K = Getfloat("InputFieldK"); float B = Getfloat("InputFieldB"); addString("InputFieldD", B - K); } if (name == "InputFieldD") { float K = Getfloat("InputFieldK"); float D = Getfloat("InputFieldD"); addString("InputFieldB", D + K); } } } public static void minmax(string L) { L = "InputField" + L; float min = GetfloatMinMax(L, "min"); float max = GetfloatMinMax(L, "max"); float AI = Getfloat(L); if (AI < min) AI = min; if (AI > max) AI = max; addString(L, AI); } public static bool checkBool(string Mesure) { bool check = false; if (Get.o2("DIMS", Mesure).activeInHierarchy == true) check = true; return check; } public static bool checkBoolNEWCab(string Mesure) { bool check = false; if (Get.o2("ADDINPUTS/DIMS", Mesure).activeInHierarchy == true) check = true; return check; } public static float Getfloat(string Mesure) { print("Mesure===="+Mesure); print("_G.VTcat===="+_G.VTcat); float v = 0; if (_G.VTcat != "TMP") { if (Mesure.IndexOf("Fix") != -1) v = DOIT.ConvertStringToNumber(Get.o2("SHOWSELECTION/DIMS", Mesure).GetComponent().text); if (Mesure.IndexOf("Input") != -1) v = DOIT.ConvertStringToNumber(Get.o2("SHOWSELECTION/DIMS", Mesure).GetComponent().text); } else { if (Mesure.IndexOf("Fix") != -1) v = DOIT.ConvertStringToNumber(Get.o2("SHOWSELECTION/DIMS", Mesure).GetComponent().text); if (Mesure.IndexOf("Input") != -1) v = DOIT.ConvertStringToNumber(Get.o2("SHOWSELECTION/DIMS", Mesure).GetComponent().text); } return v; } public static float GetfloatMinMax(string Mesure, string mm) { float v = 0; v = DOIT.ConvertStringToNumber(Get.o3("DIMS", Mesure, mm).gameObject.GetComponent().text); return v; } public static void addString(string Mesure, float value) { string VS = DOIT.CNs(value); if (_G.VTcat != "TMP") { if (Mesure.IndexOf("Fix") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; if (Mesure.IndexOf("Input") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; } else { if (Mesure.IndexOf("Fix") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; if (Mesure.IndexOf("Input") != -1) Get.o2("DIMS", Mesure).gameObject.GetComponent().text = VS; } } public void SetBvalue() { print(this.transform.Find("Label").GetComponent().text); float valueD = DOIT.ConvertStringToNumber(DOIT.CSs(GameObject.Find("DropdownD").transform.Find("Label").GetComponent().text)); float valueK = DOIT.ConvertStringToNumber(FixK.text); float value = valueD + valueK; FixB.gameObject.GetComponent().text = value.ToString(); } //Test public static void AddPATERN1(GameObject PATERN) { string path = "CABINETpnl/SHOWSELECTION/MODEL/"; if (_G.PNL == "NewCAB") { path = "CABINETpnl/ADDINPUTS/MODEL/"; } DOIT.DELETEAllChild(path + PATERN.name); _G.CODEPATERN = _G.CODEPATERN.Replace(",", "_"); GameObject DS = new GameObject(); DS.name = "doorPatern"; string[] CodeS = _G.CODEPATERN.Split('_'); float sx = DOIT.ConvertStringToNumber(CodeS[3]); float sy = DOIT.ConvertStringToNumber(CodeS[4]); float sz = 0.625f; float XW = DOIT.ConvertStringToNumber(CodeS[0]); float YH = DOIT.ConvertStringToNumber(CodeS[1]); float px = -XW / 2f + sx / 2f; float py = YH / 2f - sy / 2f; float b = 0;//Glass.getBorder(C[61].Substring(4, 3)); GameObject knob = new GameObject(); _G.RTOT = 1; RectTransform rt = PATERN.transform.GetComponent(); float swide = rt.sizeDelta.x; float swheigt = rt.sizeDelta.y; sch = swheigt / YH; scw = swide / XW; CreateDoor(DS, "1", CodeS[2], CodeS[0], sx - 0.0f, sy - 0.0f, sz, px, py, b, PATERN.name); if (CodeS[5] != "0") { Addknob(DS,"1", sx, sy, CodeS[5], px, py,CodeS[2]); } for (int i = 0; i < 25; i++) { int a = i * 4; if (CodeS.Length > 6 + a) { px += DOIT.ConvertStringToNumber(CodeS[3 + a])*0.5f + DOIT.ConvertStringToNumber(CodeS[7 + a])*0.5f; if (px >= XW / 2) { _G.RTOT += 1; px = -XW / 2f + DOIT.ConvertStringToNumber(CodeS[7 + a]) / 2f; py -= DOIT.ConvertStringToNumber(CodeS[4 + a]) / 2 + DOIT.ConvertStringToNumber(CodeS[8 + a]) / 2; } //door CreateDoor(DS, (i + 2).ToString(), CodeS[6 + a], CodeS[0], DOIT.ConvertStringToNumber(CodeS[7 + a]) - 0.0f, DOIT.ConvertStringToNumber(CodeS[8 + a]) - 0.0f, sz, px, py, b, PATERN.name); //knob if (CodeS[9 + a] != "0") { Addknob(DS,(i + 2).ToString(), DOIT.ConvertStringToNumber(CodeS[7 + a]), DOIT.ConvertStringToNumber(CodeS[8 + a]), CodeS[9 + a], px, py,CodeS[6 + a]); } } }//fin for DS.transform.SetParent(PATERN.transform, true); DS.transform.localScale = new Vector3(scw, sch, 1); DS.transform.localPosition = new Vector3(0, 0, 0); //Allbtncode(); float W = DOIT.ConvertStringToNumber(CodeS[0]); float H = DOIT.ConvertStringToNumber(CodeS[1]); string D1 = Del0(W) + " x " + Del0(H); } public static void AddPATERN2(GameObject PATERN) { string path = "CABINETpnl/SHOWSELECTION/MODEL/"; if (_G.PNL == "NewCAB") { path = "CABINETpnl/ADDINPUTS/MODEL/"; } DOIT.DELETEAllChild(path + PATERN.name); _G.CODEPATERN2 = _G.CODEPATERN2.Replace(",", "_"); GameObject DS = new ("doorPatern"); string[] CodeS2 = _G.CODEPATERN2.Split('_'); float sx = DOIT.ConvertStringToNumber(CodeS2[3]); float sy = DOIT.ConvertStringToNumber(CodeS2[4]); float sz = 0.625f; float XW = DOIT.ConvertStringToNumber(CodeS2[0]); float YH = DOIT.ConvertStringToNumber(CodeS2[1]); float px = -XW / 2f + sx / 2f; float py = YH / 2f - sy / 2f; float b = 0;//Glass.getBorder(C[61].Substring(4, 3)); float skew= XW/2; GameObject knob = new GameObject(); _G.RTOT = 1; RectTransform rt = PATERN.transform.GetComponent(); float swide = rt.sizeDelta.x; float swheigt = rt.sizeDelta.y; sch = swheigt / YH; scw = swide / XW; CreateDoor(DS, "1", CodeS2[2], CodeS2[0], sx - 0.0f, sy - 0.0f, sz, px, py, b, PATERN.name); if (CodeS2[5] != "0") { Addknob(DS,"1", sx, sy, CodeS2[5], px, py,CodeS2[2]); } if (_G.RCAT == "6" || _G.RCAT == "7" || _G.RCAT == "12" || _G.RCAT == "13") { CreateDoor(DS, "1B", CodeS2[2], CodeS2[0], sx - 0.0f, sy - 0.0f, sz, px + _G.D2W, py, b, PATERN.name); if (CodeS2[5] != "0") { Addknob(DS,"1", sx, sy, CodeS2[5], px + _G.D2W, py,CodeS2[2]); } } for (int i = 0; i < 25; i++) { int a = i * 4; if (CodeS2.Length > 6 + a) { px += DOIT.ConvertStringToNumber(CodeS2[3 + a])*0.5f + DOIT.ConvertStringToNumber(CodeS2[7 + a])*0.5f; if (px >= XW / 2) { _G.RTOT += 1; px = -XW / 2f + DOIT.ConvertStringToNumber(CodeS2[7 + a]) / 2f; py -= DOIT.ConvertStringToNumber(CodeS2[4 + a]) / 2 + DOIT.ConvertStringToNumber(CodeS2[8 + a]) / 2; } //door CreateDoor(DS, (i + 2).ToString(), CodeS2[6 + a], CodeS2[0], DOIT.ConvertStringToNumber(CodeS2[7 + a]) - 0.0f, DOIT.ConvertStringToNumber(CodeS2[8 + a]) - 0.0f, sz, px, py, b, PATERN.name); //knob if (CodeS2[9 + a] != "0") { Addknob(DS,(i + 2).ToString(), DOIT.ConvertStringToNumber(CodeS2[7 + a]), DOIT.ConvertStringToNumber(CodeS2[8 + a]), CodeS2[9 + a], px, py,CodeS2[6 + a]); knob.transform.SetParent(DS.transform); } if (_G.RCAT == "6" || _G.RCAT == "7" || _G.RCAT == "12" || _G.RCAT == "13") { CreateDoor(DS, (i + 2).ToString() + 'B', CodeS2[6 + a], CodeS2[0], DOIT.ConvertStringToNumber(CodeS2[7 + a]) - 0.0f, DOIT.ConvertStringToNumber(CodeS2[8 + a]) - 0.0f, sz, px + _G.D2W, py, b, PATERN.name); if (CodeS2[9 + a] != "0") { Addknob(DS,(i + 2).ToString(), DOIT.ConvertStringToNumber(CodeS2[7 + a]), DOIT.ConvertStringToNumber(CodeS2[8 + a]), CodeS2[9 + a], px + _G.D2W, py,CodeS2[6 + a]); } } DS.transform.SetParent(PATERN.transform, true); DS.transform.localScale = new Vector3(scw, sch, 1); } }//fin for DS.transform.SetParent(PATERN.transform, true); DS.transform.localScale = new Vector3(scw, sch, 1); //DS.transform.localPosition = new Vector3(-DOIT.ConvertStringToNumber(CodeS2[3])*scw/2, 0, 0); DS.transform.localPosition = new Vector3(0, 0, 0); //Allbtncode(); } public static void CreateDoor(GameObject ds, string N, string p, string wp, float Sx, float Sy, float Sz, float Px, float Py, float b, string PATERN) { //float oy = 0; string btnName = ""; GameObject Doorbtn = Get.o2("CABINETpnl", "PATERNBTN"); if (p == "p") { btnName = "DOOR"; } if (p == "d") { btnName = "DRAW"; } if (p == "t") { btnName = "TAMB"; } if (p == "o") { btnName = "OPEN"; } if (p == "w") { btnName = "WINE"; } if (p == "g") { btnName = "GLAS"; } if (p == "c") { btnName = "CUTO"; } if (p == "dd"){ btnName = "DOUB"; } GameObject R = Instantiate(Doorbtn, new Vector3(0, 0, 0), Quaternion.identity); R.SetActive(true); R.name = btnName + N.ToString(); R.transform.Find("Line1").transform.GetComponent().sizeDelta = new(Sx, Sy); R.transform.position = new Vector3(Px, Py, 0); if (_G.RTOT == 1) { R1 = new(0, Py); _G.ROWH1[0] = Sy; } if (_G.RTOT == 2) { R2 = new(0, Py); _G.ROWH1[1] = Sy; } if (_G.RTOT == 3) { R3 = new(0, Py); _G.ROWH1[2] = Sy; } if (_G.RTOT == 4) { R4 = new(0, Py); _G.ROWH1[3] = Sy; } if (_G.RTOT == 5) { R5 = new(0, Py); _G.ROWH1[4]= Sy; } if (_G.RTOT == 6) { R6 = new(0, Py); _G.ROWH1[5]= Sy; } R.transform.SetParent(ds.transform, true); UILineRenderer ui = R.transform.Find("Line1").GetComponent(); float ofx = Sx / 2; float ofy = Sy / 2; float skew=0;//wide door patern float skewcoffset=0;//wide door patern if(PATERN=="SkewPaternM.5.L.B"){skew=0.35f; skewcoffset=-2.2f;} if(PATERN=="SkewPaternM.5.R.B"){skew=-0.35f; skewcoffset=2.2f;} if(PATERN=="SkewPaternM.8.L.B"){skew=0.35f; skewcoffset=-2.2f;} if(PATERN=="SkewPaternM.8.R.B"){skew=-0.35f; skewcoffset=2.2f;} if(PATERN=="SkewPaternM.13.L.B"){skew=-0.45f; skewcoffset=2.7f;}//2.2 if(PATERN=="SkewPaternM.13.R.B"){skew=0.45f; skewcoffset=-3.0f;}//-2.0f trop haut Vector3 Rpos=R.transform.localPosition; R.transform.localPosition=new( Rpos.x, Rpos.y+skewcoffset, Rpos.z); float wd=DOIT.ConvertStringToNumber(wp);//wide door patern float yskew1=(wd/2+Px-Sx/2)*skew; float yskew2=(wd/2+Px+Sx/2)*skew; Vector2 p1; Vector2 p2; Vector2 p3; Vector2 p4; Vector2 p5; Vector2 p6; Vector2 p7; Vector2 p8; if(p != "dd"){ p1 = new (0, 0+ yskew1); p2 = new (0, Sy+ yskew2); p3 = new (Sx, Sy+ yskew2); p4 = new (Sx, 0+ yskew1); p5 = new (0,0+ yskew1); List pointlist = new(){p1, p2,p3, p4, p5}; ui.Points = pointlist.ToArray(); ui.LineThickness = 200 / (sch * 100); ui.color = Color.white; } if(p == "dd"){ p1 = new (0,0 + yskew1); p2 = new (0, Sy+ yskew2); p3 = new (Sx, Sy+ yskew2); p4 = new (Sx, Sy/2); p5 = new (0,Sy/2); p6 = new (0, 0+ yskew1); p7 = new (Sx, 0+ yskew1); p8 = new (Sx ,Sy/2); List pointlist = new(){p1, p2,p3, p4, p5 , p6, p7, p8}; ui.Points = pointlist.ToArray(); ui.LineThickness = 200 / (sch * 100); ui.color = Color.white; } if (p == "w") { PaternDraw.AddSprite(R, p, Sx, Sy, 0, 0, 0); } if (p == "o") { float posx = -Sx / 2 + ofx + Px; float posy = -Sy / 2 + ofy + Py; PaternDraw.DrawlineOpen(R, Sx, Sy, posx, posy, _G.SC[0], 50, 1); } if (p == "t") { PaternDraw.DrawlineTambour(R, Sx, Sy, -Sx / 2 + ofx + Px, -Sy / 2 + ofy + Py, _G.SC[0], 50, 1, 0.5f); } if (p == "g") { PaternDraw.DrawlineGlass(R, Sx, Sy, -Sx / 2 + ofx + Px, -Sy / 2 + ofy + Py, _G.SC[0], 50, 1, 0.5f); } if (p == "c") { PaternDraw.DrawlineCutout(R, Sx, Sy, -Sx / 2 + ofx + Px, -Sy / 2 + ofy + Py, _G.SC[0], 50, 1, 0.5f); } } public static string Del0(float FV) { string SV = FV.ToString("F3"); if (SV.IndexOf(".") != -1) { if (SV.Substring(SV.Length - 1, 1) == "0") SV = SV.Substring(0, SV.Length - 1); if (SV.Substring(SV.Length - 1, 1) == "0") SV = SV.Substring(0, SV.Length - 1); if (SV.Substring(SV.Length - 1, 1) == "0") SV = SV.Substring(0, SV.Length - 1); if (SV.Substring(SV.Length - 1, 1) == ".") SV = SV.Substring(0, SV.Length - 1); } return SV; } public static void Addknob(GameObject DS,string N, float sx, float sy, string pos, float px, float py, string cat) { GameObject Knob = Get.o2("BTNPATERN", "knobMark"); GameObject K = Instantiate(Knob, new Vector3(0, 0, 0), Quaternion.identity); GameObject K2 = Instantiate(Knob, new Vector3(0, 0, 0), Quaternion.identity); K.SetActive(true); K.name = "k" + N; K.transform.GetComponent().sizeDelta = new(3, 3); bool TwoDoors=false; if(cat=="dd"){TwoDoors=true;} float dx = sx / 2 - sx / 11; float dy = sy / 2 - sy / 10; float ofy123=0; float ofy456=0f; float ofy789=0f; float scalew = 2f / scw; float scaleh = 2f / sch; if(!TwoDoors){ knobset.Reposition(pos, K,px, py,1, dx,dy,ofy123,ofy456,ofy789,0 ); } if(TwoDoors){ K2.SetActive(true); K2.name = "k" + N+"B"; K2.transform.GetComponent().sizeDelta = new(3, 3); ofy456=sy*0.25f; ofy789=sy*0.5f; knobset.Reposition(pos, K, px, py,1, dx,dy,ofy123,ofy456,ofy789,0 ); ofy123=-sy*0.5f; ofy456=-sy*0.25f; ofy789=0f; knobset.Reposition(pos, K2, px, py,1,dx,dy,ofy123,ofy456,ofy789,0 ); K2.transform.localScale = new Vector3(scalew, scaleh, 1); K2.transform.SetParent(DS.transform); } // if (pos == "1") { px = px - sx / 2 + 2; py = py + sy / 2 - 2; } // if (pos == "2") { py = py + sy / 2 - 2; } // if (pos == "3") { px = px + sx / 2 - 2; py = py + sy / 2 - 2; } // if (pos == "4") { px = px - sx / 2 + 2; } // if (pos == "5") { } // if (pos == "6") { px = px + sx / 2 - 2; } // if (pos == "7") { px = px - sx / 2 + 2; py = py - sy / 2 + 2; } // if (pos == "8") { py = py - sy / 2 + 2; } // if (pos == "9") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } // if (pos == "10") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } // if (pos == "11") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } // if (pos == "12") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } // if (pos == "13") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } // if (pos == "14") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } // if (pos == "15") { px = px + sx / 2 - 2; py = py - sy / 2 + 2; } //K.transform.position = new Vector3(px, py, 0); K.transform.localScale = new Vector3(scalew, scaleh, 1); K.transform.SetParent(DS.transform); //return K; } //public static void Allbtncode() //{ // if (_G.RTOT >= 1) // { // Setbtncode(_G.ROW1, "editRow1"); // } // if (_G.RTOT >= 2) // { // Setbtncode(_G.ROW2, "editRow2"); // } // if (_G.RTOT >= 3) // { // Setbtncode(_G.ROW3, "editRow3"); // } // if (_G.RTOT >= 4) // { // Setbtncode(_G.ROW4, "editRow4"); // } // if (_G.RTOT >= 5) // { // Setbtncode(_G.ROW5, "editRow5"); // } // if (_G.RTOT == 6) // { // Setbtncode(_G.ROW6, "editRow6"); // } //} //public static void Setbtncode(string BCT, string papa) //{ // string[] bct = BCT.Split(','); // string[] btn1 = (",,,").Split(','); // string[] btn2 = (",,,").Split(','); // string[] btn3 = (",,,").Split(','); // string[] btn4 = (",,,").Split(','); // if (bct.Length >= 4) // { // for (int i = 0; i < 4; i++) // { // btn1[i] = bct[i]; // } // } // if (bct.Length >= 8) // { // for (int i = 4; i < 8; i++) // { // btn2[i - 4] = bct[i]; // } // } // if (bct.Length >= 12) // { // for (int i = 8; i < 12; i++) // { // btn3[i - 8] = bct[i]; // } // } // if (bct.Length >= 16) // { // for (int i = 12; i < 16; i++) // { // btn4[i - 12] = bct[i]; // } // } // if (papa == "editRow1") { _G.btn11 = btn1; _G.btn12 = btn2; _G.btn13 = btn3; _G.btn14 = btn4; } // if (papa == "editRow2") { _G.btn21 = btn1; _G.btn22 = btn2; _G.btn23 = btn3; _G.btn24 = btn4; } // if (papa == "editRow3") { _G.btn31 = btn1; _G.btn32 = btn2; _G.btn33 = btn3; _G.btn34 = btn4; } // if (papa == "editRow4") { _G.btn41 = btn1; _G.btn42 = btn2; _G.btn43 = btn3; _G.btn44 = btn4; } // if (papa == "editRow5") { _G.btn51 = btn1; _G.btn52 = btn2; _G.btn53 = btn3; _G.btn54 = btn4; } // if (papa == "editRow6") { _G.btn61 = btn1; _G.btn62 = btn2; _G.btn63 = btn3; _G.btn64 = btn4; } //} }