using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class AddToPanel : MonoBehaviour { public static void ModelsPanel(Dictionary library) { DOIT.DeleteAllUIElementsStartingFrom(_G.PON, VisualElementUI.Models); GameObject BTNMODEL = Get.o1("PNL/" + _G.PON + "/BASEBTN/BTNMODEL"); GameObject List = Get.o1(_G.PON + "/MODELS/Viewport/Content"); List modelList = new(); List IconList = new(); string subfilter = Get.ToggleOnInChild(_G.PON + "/SUB_FILTERS/Viewport/Content"); string filter = Get.ToggleOnInChild("PNL/" + _G.PON + "/FILTERS/Viewport/Content"); foreach (var data in library) { var element = data.Value; string filterValue = element.GetPropertyValue(Define.GetHeaderByValue(filter)); if (!string.IsNullOrEmpty(filterValue) && filterValue == subfilter) { string model = element.GetPropertyValue(CsvHeaders.Model); string icon = element.GetPropertyValue(CsvHeaders.Image_Icon); if (string.IsNullOrWhiteSpace(model)) { model = "DBH"; } if (string.IsNullOrWhiteSpace(icon)) { icon = "2"; } if (model == "1") model = "DBH"; if (!modelList.Contains(model)) { IconList.Add(icon); modelList.Add(model); } } } if (modelList.Count == 1) { modelList.Add("DBV"); IconList.Add("4"); modelList.Add("DHH"); IconList.Add("3"); modelList.Add("DHT"); IconList.Add("1"); modelList.Add("DHV"); IconList.Add("4"); modelList.Add("PBBH"); IconList.Add("3"); modelList.Add("PBBV"); IconList.Add("4"); modelList.Add("PBHH"); IconList.Add("1"); modelList.Add("PBHT"); IconList.Add("3"); modelList.Add("PBHV"); IconList.Add("4"); } for (int i = 0; i < modelList.Count; i++) { GameObject C = Instantiate(BTNMODEL); C.name = modelList[i]; C.transform.Find("Background").GetComponent().sprite = Resources.Load("ICONS/MOLDING_MODELS/" + _G.PNL + "/Panel_" + IconList[i]); //MOLDING_MODELS/Panel1 C.transform.Find("Image").transform.Find("Text").gameObject.GetComponent().text = modelList[i]; if (i < 8) { C.SetActive(true); } C.transform.SetParent(List.transform, false); C.transform.SetSiblingIndex(modelList.Count - 1); } Set.ToggleGroupToAllChild(_G.PON + "/MODELS/Viewport/Content"); Get.o1(_G.PON + "/MODELS/Viewport/Content").transform.GetChild(0).GetComponent().isOn = true; CabTextureColors(library); StaticCoroutine.Start(WaitHideScroller("MODELS")); } public static void CabTextureColors(Dictionary Library) { DOIT.DeleteAllUIElementsStartingFrom(_G.PON, VisualElementUI.TextureColors); GameObject BTNSELECTION = Get.o2(_G.PON + "BASEBTN", "BTNTEXCOL"); GameObject List = Get.o1(_G.PON + "/TEXTCOL/Viewport/Content"); List colorIDList = new(); string filter = Get.ToggleOnInChild(_G.PON + "/FILTERS/Viewport/Content"); string subfilter = Get.ToggleOnInChild(_G.PON + "/SUB_FILTERS/Viewport/Content"); var filters = Library.ElementAt(0).Value.GetFilters(); if (filters.ContainsKey(filter) && (!string.IsNullOrEmpty(filters[filter]))) { for (int i = 0; i < Library.Count; i++) { CsvData data = Library.ElementAt(i).Value; string filterValue = data.GetPropertyValue(Define.GetHeaderByValue(filter)); if (!string.IsNullOrEmpty(filterValue) && filterValue == subfilter) { string colorName = data.GetPropertyValue(CsvHeaders.ID); if (colorIDList.Contains(colorName)) continue; if (subfilter != "Ukitchenit") colorIDList.Add(colorName); //j++; } } } for (int i = 0; i < colorIDList.Count; i++) { GameObject C = Instantiate(BTNSELECTION); C.name = colorIDList[i]; if (_G.PNL == "CounterPnl") { C.transform.Find("Background").GetComponent().material = CREATE.GetCounterMat(colorIDList[i],"PNL"); } else { //C.transform.Find("Background").GetComponent().material = CREATE.Texture_CAB(colorIDList[i], 18, 18, "0", _G.PNL,"PNL"); // CanvasRenderer TC= C.transform.Find("Background").GetComponent(); // TC.transform.localScale=new(5.55f,5.55f,5.55f); // Material Mat=CREATE.Texture_CAB(colorIDList[i], 18, 18, "0", "CabTexture"); // TC.SetMesh(UIMeshRenderer.CreateCabTextureMesh(18,18)); // TC.SetMaterial(Mat, null); } string displayName = ""; if (_G.UseNewCsvFormat) { displayName = Get.LibraryValue(colorIDList[i], CsvHeaders.Color, Library) /*+ " " + Get.LibraryValue(colorIDList[i], CsvHeaders.Language, Library)*/; } else { displayName = Get.LibraryValue(colorIDList[i], CsvHeaders.Color, Library); if (string.IsNullOrEmpty(displayName)) { displayName = colorIDList[i]; } } C.transform.Find("Image").transform.Find("Text").gameObject.GetComponent().text = displayName; int showQty = 24; //if (_G.PON == "PANELpnl") {showQty = 18;} if (i < showQty + 1) { C.gameObject.SetActive(true); } C.transform.SetParent(List.transform, false); C.transform.SetSiblingIndex(colorIDList.Count - 1); } Get.o1(_G.PON + "/SHOWSELECTION/").GetComponent().alpha = 0; Set.ToggleGroupToAllChild(_G.PON + "/TEXTCOL/Viewport/Content"); //Click first selection Get.o1(_G.PON + "/TEXTCOL/Viewport/Content").transform.GetChild(0).GetComponent().isOn = true; GameObject Button = Get.o1(_G.PON + "/TEXTCOL/Viewport/Content").transform.GetChild(0).gameObject; Button.GetComponent().isOn = true; //if (_G.PON == "UNIVERSALpnl") UNIVERSALPNL.ShowSelected(Button.name); //if (_G.PON == "MOLDINGpnl") { MoldingPNL.ShowSelectedMolding(Button.name); } //if (_G.PON == "PANELpnl") { PanelPNL.ModelSelected(); PanelPNL.ShowSelectedPanel(Button.name); } StaticCoroutine.Start(WaitHideScroller("TEXTCOL")); } // public static void DoorTextureColors(Dictionary Library) // { // DOIT.DeleteAllUIElementsStartingFrom(_G.PON, VisualElementUI.TextureColors); // List idList = new List(); // List colorlist = new List(); // string filter = Get.ToggleOnInChild(_G.PON + "/FILTERS/Viewport/Content"); // string subfilter = Get.ToggleOnInChild(_G.PON + "/SUB_FILTERS/Viewport/Content"); // string Model = Get.ToggleOnInChild(_G.PON + "/MODELS/Viewport/Content"); // GameObject PNL = Get.o2(_G.PON + "TEXTCOL/Viewport", "Content"); // GameObject BTN = Get.o2(_G.PON + "BASEBTN", "BTNTEXCOL"); // foreach (var keyValue in Library) // { // var data = keyValue.Value; // if (Model == data.GetPropertyValue(CsvHeaders.Model) && subfilter == data.GetPropertyValue(Define.GetHeaderByValue(filter))) // { // string ID = data.GetPropertyValue(CsvHeaders.ID); // string Color = data.GetPropertyValue(CsvHeaders.Color); // if (!idList.Contains(ID)) { idList.Add(ID); } // if (!colorlist.Contains(Color)) { colorlist.Add(Color); } // } // } // PrepareColorPreviewThumbnails(idList, colorlist, Library, PNL, BTN); // Set.ToggleGroupToAllChild(_G.PON + "/TEXTCOL/Viewport/Content"); // Get.o1(_G.PON + "/SHOWSELECTION/").GetComponent().alpha = 0; // StaticCoroutine.Start(WaitHideScroller("TEXTCOL")); // //Click first selection // GameObject Button = Get.o1(_G.PON + "/TEXTCOL/Viewport/Content").transform.GetChild(0).gameObject; // Button.GetComponent().isOn = true; // DoorCabPNL.showSelected(Button.name); // } private static void PrepareColorPreviewThumbnails(List idList, List colorlist, Dictionary library, GameObject PNL, GameObject BTN) { for (int i = 0; i < colorlist.Count; i++) { GameObject M = Instantiate(BTN); M.name = idList[i]; //Debug.Log(idList[i] + " open panel " + _G.PNL); string colorCode = Get.LibraryValue(idList[i], CsvHeaders.Color, library); string colorName = Get.LibraryValue(idList[i], CsvHeaders.Language, library); string displayName = ""; if (_G.UseNewCsvFormat) { displayName = colorCode; /*+ " " + colorName;*/ } else { displayName = colorCode; } M.transform.Find("Image").transform.Find("Text").gameObject.GetComponent().text = displayName; //M.transform.Find("BackgroundTex").GetComponent().material = _G.TEXTURE_PNL;//Resources.Load("MATERIALS/GlobalPNL/DoorMatPNL"); M.transform.Find("BackgroundTex").GetComponent().material = DoorMaterial.getDoorTexture(idList[i], 18, 18,"PNL"); if (i < 18) M.gameObject.SetActive(true); M.transform.SetParent(PNL.transform, false); M.transform.SetSiblingIndex(colorlist.Count - 1); } } public static void DecoObject3D(List Library, string ImagePath, string NameObject) { print("_G.PON===" + _G.PON); GameObject PNL = Get.o2(_G.PON + "/MODEL/Viewport", "Content"); GameObject BTN = Get.o2(_G.PON, "BTNSELECTION"); DOIT.DELETEAllObjectChild(PNL); for (int i = 0; i < Library.Count; i++) { GameObject O = Instantiate(BTN); O.transform.SetParent(PNL.transform, false); O.SetActive(true); O.name = NameObject[..4] + (101 + i).ToString(); O.transform.Find("Image/Text").GetComponent().text = (i + 1).ToString();//TRANS.This("T_" + NameObject) + " " + (i + 1).ToString(); O.transform.Find("Background").GetComponent().sprite = Resources.Load(ImagePath + (101 + i).ToString()); } Set.ToggleGroupToAllChild(_G.PON + "/MODEL/Viewport/Content"); } public static IEnumerator WaitHideScroller(string PnlName) { int qty = Get.o2(_G.PON + "/" + PnlName + "/Viewport", "Content").transform.childCount; //yield return new WaitForSeconds(qty * 0.00005f); int ind = 3; if (_G.PNL == "CabTexture" || _G.PNL == "Counter") { ind = 4; } if (_G.PON == "TEXTUREPNL") { ind = 5; } if (_G.PON == "CABDOORpnl" && PnlName == "MODELS") { ind = 1; } if (_G.PON == "UNIVERSALpnl") { ind = 4; } if (_G.PON == "PANELpnl" && PnlName == "MODELS") { ind = 1; } Hide.SETSCROLLER(PnlName, 6, ind, qty); yield break; } }