using UnityEngine.UI; using UnityEngine; using System.Collections.Generic; using TMPro; using Unity.Mathematics; public class NEWCAB : MonoBehaviour { //INPUTS public TMP_Dropdown Library; public TMP_InputField Unique_Name; public TMP_Dropdown CabCat; public TMP_Dropdown SubCabCat; public TMP_InputField DESL1; public TMP_InputField DESL2; public TMP_InputField DESL3; //OPTIONS public TMP_InputField CUSTOM_L1; public TMP_InputField CUSTOM_L2; public TMP_InputField CUSTOM_L3; public TMP_Dropdown CUSDROP_L1; public TMP_Dropdown CUSDROP_L2; public TMP_Dropdown CUSDROP_L3; public GameObject SWITCH; public GameObject ICONS; public static Image ImageModel; static List DIMENSIONS; static string Refcab; static string CabLib; static string ModelNumber;//B1,W1,T1.... static string Category; //Used by Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION/CREATENEWCAB public void Open() { //Set Refferences Get.o2("CABINETpnl","ROWHEIGHTPNL").SetActive(false); Refcab=_G.SC[0]; CabLib="Cabinet";if(UIT.TogOn("FILTERS")=="Ukitchenit")CabLib="CabinetUkitchenit"; ModelNumber=UIT.Value(CabLib,Refcab,"Model"); Category=UIT.Value(CabLib,Refcab,"Category"); //GET DIMS FROM SELECTIONS DIMENSIONS=DIMS.GetFromSelection(); //OPEN PANEL _G.PNL = "NewCAB"; Allfalse.SetCabPnlOpen(); Get.o2("CABINETpnl", "ADDINPUTS").SetActive(true); //SET INPUTS FillInputs(); //SET DIMENSIONS Dimensions(); //SET OPTIONS Options(); Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "DELETEFROMLIST").SetActive(false); Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "CREATENEWCAB").SetActive(false); Get.o2("Canvas/Panel_SCENE/PNL/CABINETpnl/SHOWSELECTION", "RowHeightBtn").SetActive(true); } public void FillInputs() { string CabLib="Cabinet";if(UIT.TogOn("FILTERS")=="Ukitchenit")CabLib="CabinetUkitchenit"; //LIBRARY Library.ClearOptions(); if (_G.L == 1) Library.AddOptions(_SC.LIB1); if (_G.L == 2) Library.AddOptions(_SC.LIB2); if (_G.L == 3) Library.AddOptions(_SC.LIB3); string LibraryName=UIT.Value(CabLib,_G.SC[0],"Library_Name"); if(LibraryName=="Kitchen")Library.value=0; if(LibraryName=="Bathroom")Library.value=1; //CABINET NAME Unique_Name.text= UIT.Value(CabLib,_G.SC[0],"Unique_Name"); //MODEL _G.SC[1] = ModelNumber; _G.SC[2] = Category; //CATEGORY CabCat.ClearOptions(); if (_G.L == 1) CabCat.AddOptions(_SC.CAT1); if (_G.L == 2) CabCat.AddOptions(_SC.CAT2); if (_G.L == 3) CabCat.AddOptions(_SC.CAT3); if(Category=="BASE")CabCat.value=0; if(Category=="WALL")CabCat.value=2; if(Category=="TALL")CabCat.value=4; if(Category=="CBASE")CabCat.value=5; if(Category=="CWALL")CabCat.value=6; //SUB CATEGORY SubCatChange(); //DESCRIPTIONS DESL1.text= UIT.Value(CabLib,_G.SC[0],"Des_L1"); DESL2.text= UIT.Value(CabLib,_G.SC[0],"Des_L2"); DESL3.text= UIT.Value(CabLib,_G.SC[0],"Des_L3"); } public static void Dimensions(){ ImageModel=Get.o2("CABINETpnl/ADDINPUTS/SIZES","MODEL").GetComponent(); int Cab_Image=UIT.Ind(CabLib,"Cab_Image"); string[] c = UIT.GetLibraryLine(CabLib,_G.SC[0]); _G.RCAT = c[Cab_Image];//Cab_Image; string mod = _G.RCAT.Split('.')[0] + "." + _G.RCAT.Split('.')[1] + "." + _G.RCAT.Split('.')[2]; ImageModel.GetComponent().sprite = Resources.Load("CABIMAGE/" + mod); //SET PATERN ON MODEL if(string.IsNullOrEmpty(_G.CODEPATERN)){ int Pattern_Door_1=UIT.Ind(CabLib,"Pattern_Door_1"); int Pattern_Door_2=UIT.Ind(CabLib,"Pattern_Door_2"); _G.CODEPATERN = c[Pattern_Door_1]; _G.CODEPATERN2 = c[Pattern_Door_2]; } foreach(Transform O in Get.o2("ADDINPUTS/SIZES", "DIMS").transform ){ O.gameObject.SetActive(false);} AddDim("A",0); AddDim("B",1); AddDim("C",2); AddDim("D",3); AddDim("E",4); AddDim("F",5); AddDim("K",6); if(ModelNumber=="B1"){ ResetDim.ResetNew("D_Value"); } foreach(Transform O in Get.o2("ADDINPUTS/SIZES", "MODEL").transform ){ Set.alpha(O.gameObject,false);} UIT_SetCab.Paternskew(_G.RCAT); } public void Options(){ //print("CabCat.value===="+CabCat.value); //ACC CUSTOM CUSTOM_L1.text=""; CUSTOM_L2.text=""; CUSTOM_L3.text=""; CUSDROP_L1.options.Clear(); CUSDROP_L2.options.Clear(); CUSDROP_L3.options.Clear(); //All swict off DOIT.AllChildOff(SWITCH); DOIT.AllChildOff(ICONS); //All icons off if(Category=="BASE"){ //Set switch SWITCH.transform.Find("KickFront").gameObject.SetActive(true); SWITCH.transform.Find("KickSide").gameObject.SetActive(true); SWITCH.transform.Find("KickBack").gameObject.SetActive(true); SWITCH.transform.Find("BackMDF").gameObject.SetActive(true); SWITCH.transform.Find("AllSideFinish").gameObject.SetActive(true); SWITCH.transform.Find("AllowSink").gameObject.SetActive(true); SWITCH.transform.Find("FullTop").gameObject.SetActive(true); //SWITCH.transform.Find("SideNotch").gameObject.SetActive(true); //Set icons ICONS.transform.Find("Side Panel").gameObject.SetActive(true); ICONS.transform.Find("Kick model").gameObject.SetActive(true); } if(Category=="WALL"|| Category=="CWALL"){ //Set switch SWITCH.transform.Find("BackFinish").gameObject.SetActive(true); SWITCH.transform.Find("BackMDF").gameObject.SetActive(true); SWITCH.transform.Find("UnderFinish").gameObject.SetActive(true);//T_BackFinish SWITCH.transform.Find("AllSideFinish").gameObject.SetActive(true); //Set icons ICONS.transform.Find("Side Panel").gameObject.SetActive(true); ICONS.transform.Find("Kick model").gameObject.SetActive(true); } if(Category=="TALL"){ //Set switch SWITCH.transform.Find("KickFront").gameObject.SetActive(true); SWITCH.transform.Find("KickSide").gameObject.SetActive(true); SWITCH.transform.Find("KickBack").gameObject.SetActive(true); SWITCH.transform.Find("AllSideFinish").gameObject.SetActive(true); SWITCH.transform.Find("BackMDF").gameObject.SetActive(true); //Set icons ICONS.transform.Find("Side Panel").gameObject.SetActive(true); ICONS.transform.Find("Kick model").gameObject.SetActive(true); } if(Category=="CBASE"){ //Set switch SWITCH.transform.Find("KickFront").gameObject.SetActive(true); SWITCH.transform.Find("KickSide").gameObject.SetActive(true); SWITCH.transform.Find("KickBack").gameObject.SetActive(true); SWITCH.transform.Find("BackMDF").gameObject.SetActive(true); SWITCH.transform.Find("AllowSink").gameObject.SetActive(true); SWITCH.transform.Find("FullTop").gameObject.SetActive(true); //SWITCH.transform.Find("SideNotch").gameObject.SetActive(true);_sc //Set icons ICONS.transform.Find("Side Panel").gameObject.SetActive(true); ICONS.transform.Find("Kick model").gameObject.SetActive(true); } } ///MODIFICATION public void SubCatChange(){ int ind =CabCat.value; string cat=CabCat.options[ind].text; //Add sub category base on category SubCabCat.ClearOptions(); SubCabCat.AddOptions(_SC.GetCat()[cat+_G.L.ToString()]); string SubCategory=UIT.Value(CabLib,_G.SC[0],"Category_L1"); int indvalue=0; if(Category=="BASE"){ indvalue=_SC.BASE1.IndexOf(SubCategory); } if(Category=="WALL"){ indvalue=_SC.WALL1.IndexOf(SubCategory); } if(Category=="TALL"){ indvalue=_SC.TALL1.IndexOf(SubCategory); } if(Category=="CBASE"){ indvalue=_SC.CBASE1.IndexOf(SubCategory); } if(Category=="CWALL"){ indvalue=_SC.CWALL1.IndexOf(SubCategory); } SubCabCat.value=indvalue; } public static void AddDim(string L, int ind) { //print("L==="+L+" ind==="+ind); //print("ModelNumber==="+ModelNumber); string Code=DIMENSIONS[ind]; print("Code "+L+" ======"+Code); if(!string.IsNullOrEmpty(Code) && Code!="0"){ GameObject Letter = Get.o2("ADDINPUTS/SIZES/DIMS",L); Letter.SetActive(true); string minValue = ""; string maxValue = ""; string currentValue = Code; if(Code.IndexOf("_")!=-1){ minValue=Code.Split('_')[0]; currentValue=Code.Split('_')[1]; maxValue=Code.Split('_')[2]; if(minValue==maxValue){minValue = ""; maxValue = "";} } if(Code.IndexOf("?")!=-1){//Add value to dropdown TMP_Dropdown DROPBOX=Letter.transform.Find(L+"drop").GetComponent(); DROPBOX.options.Clear(); string[] Drops=Code.Split('?'); foreach (string option in Drops) { DROPBOX.options.Add(new TMP_Dropdown.OptionData(option)); } currentValue=DROPBOX.options[DROPBOX.value].text; } Letter.transform.Find(L+"_Min").GetComponent().text=""; Letter.transform.Find(L+"_Max").GetComponent().text=""; Letter.transform.Find(L+"_Value").GetComponent().text=currentValue; } } public void Close() { Get.o1("CABINETpnl").transform.Find("ADDINPUTS").gameObject.SetActive(false); _G.PNL = "CabPNL"; } public void CategoryChange(){ print("CategoryChange name---"+name); int value=gameObject.GetComponent().value; string Category = gameObject.GetComponent().options[value].text; SubCabCat.ClearOptions(); SubCabCat.AddOptions(_SC.GetCat()[Category+_G.L.ToString()]); } public static void AddSubCategory(){ int ind=Get.o2(_G.PON,"CATEGORY").GetComponent().value; print("ind======="+ind); string Category="Base"; switch (ind) { case 0:case 1: case 2:case 3:Category="Base";break; case 4:case 5: case 6:case 7:Category="Wall";break; case 8: Category="Tall";break; case 9: case 10:case 11:case 12:Category="Corner Base";break; case 13:case 14: case 15:case 16:Category="Corner Wall";break; } TMP_Dropdown SubCabCat=Get.o2(_G.PON+"/INPUTS","SubCabCat").GetComponent(); SubCabCat.ClearOptions(); SubCabCat.AddOptions(_SC.GetCat()[Category+_G.L.ToString()]); } public static void AddLibrary(){ GameObject Library=Get.o2("CABCREATORpnl/INPUTS","Library"); List library = new() { TRANS.This("T_Kitchen"),TRANS.This("T_Bathroom")}; // if(_G.L==2){ // library = new() { "Kitchen","Bathroom"}; // } // if(_G.L==3){ // library = new() { "Cocina","BaƱo"}; // } Library.GetComponent().ClearOptions(); Library.GetComponent().AddOptions(library); } }