using UnityEngine; using UnityEngine.UI; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.AddressableAssets; using System.Collections; public class GLOBALSELECTION_PNL : MonoBehaviour { static CanvasRenderer _doorImageCR; private static Texture2D AdressableTextureCounter; private static Texture2D AdressableTextureSpash; static GameObject ImageCountertop; static GameObject ImageSplash; static string RecipeCountertop; static string RecipeSplash; private void OnDisable() { DisableDoorImage(); } public void StartPNL() // used by Global { StartPNL(_G.G); } public static void StartPNL(int G) { //print("_G.G======"+_G.G); _G.PON = "GLOBALSTART"; DOIT.CloseALLPNL(); GameObject PNL = GameObject.Find("PNL").transform.Find("GLOBALGPNL").gameObject; PNL.SetActive(true); //Set number of Global DOIT.AllChildOff(Get.o2("GLOBALGPNL", "GlobalNumber")); int NumberOFGlobal = int.Parse(_P.List["GLOBAL_QTY"]); _P.List["GLOBAL_QTY"] = "0"; NumberOFGlobal = 0; if (_G.PATH == "free"){ _P.List["GLOBAL_QTY"] = "0"; NumberOFGlobal = 0; } if (NumberOFGlobal != 0) { for (int i = 1; i < NumberOFGlobal + 1; i++) { Get.o2("GLOBALGPNL/GlobalNumber", "btnG" + i.ToString()).SetActive(true); } } else{ Get.o2("PNL/GLOBALGPNL", "ADDING").SetActive(true); _G.G = 1; DOIT.AllTogchildfalse(Get.o2("GLOBALGPNL", "ADDING")); Get.o2("GLOBALGPNL/ADDING", "All").transform.GetComponent().isOn = true; if (_G.SELECEDLIST.Count > 0) { Get.o2("GLOBALGPNL/ADDING", "All").transform.GetComponent().isOn = false; Get.o2("GLOBALGPNL/ADDING", "Select").transform.GetComponent().isOn = true; } _G.SelectionToAdd = SetSelectionBTN.GetSelection(); foreach(string select in _G.SelectionToAdd) { print("select===="+select); } } PNL.transform.localPosition = Vector3.zero; //All false DOIT.AllChildOff(Get.o2("GLOBALGPNL", "Selections")); if (_P.ListSwitch["DOOR_SELECT"]) { Setdoor(UIT.Global(Header.Door, _G.G)); } if (_P.ListSwitch["KICK_SELECT"]) { SetKick(UIT.Global(Header.Kick, _G.G)); } if (_P.ListSwitch["OGEE_SELECT"]) { SetOgee(UIT.Global(Header.Ogee, _G.G)); } if (_P.ListSwitch["FASCIA_SELECT"]) { SetFascia(UIT.Global(Header.Fascia, _G.G)); } if (_P.ListSwitch["VALANCE_SELECT"]) { SetValance(UIT.Global(Header.Valance, _G.G)); } if (_P.ListSwitch["EXTERIOR_SELECT"]) { Setextfinish(UIT.Global(Header.Ext, _G.G)); ; } // Setextfinish(UIT.Global(Header.Ext,_G.G));//GlobalSelectionManager.GetValue(GlobalOption.EXTPNL_2)); SetcaseSplash(UIT.Global(Header.Splash, _G.G));//(GlobalSelectionManager.GetValue(GlobalOption.SPLA_9), "Backsplash"); SetCounter(UIT.Global(Header.Counter, _G.G));//(GlobalSelectionManager.GetValue(GlobalOption.COUN_8)); SetcaseKnob("ICONS/KNOBS/", UIT.Global(Header.KnobV, _G.G), "KnobD"); SetcaseKnob("ICONS/KNOBS/", UIT.Global(Header.KnobH, _G.G), "KnobT"); GLOBALSET.G_OnGLOBAL("GLOBAL"); if (_G.User == "Admin") { Get.o2("Canvas/Panel_SCENE/PNL/GLOBALGPNL", "SaveToServer").SetActive(true); } else { Get.o2("Canvas/Panel_SCENE/PNL/GLOBALGPNL", "SaveToServer").SetActive(false); } // string Code =UIT.Global(Header.Ext, _G.G); // if (!_Add.YOUR_DOORS.Contains(Code)) { _Add.Door(Code); } } public static void Setdoor(string CODE) { // print("Setdoor CODE===="+CODE); Get.o2("GLOBALGPNL/Selections", "Door").SetActive(true); string[] code = CODE.Split('?'); //Material Mat=UIT_MATERIAL.GetMaterial(code[1]); //Material Mat90=UIT_MATERIAL.GetMaterial(code[1]); //Show door string model = UIT.Value(Library.Door, code[0], Header.Model); if (model == "D_29") model = "D_11"; float ct = 0.25f; float E_H = DOIT.ConvertStringToNumber(UIT.Value(Library.Door, code[0], Header.E_H)); float E_V = DOIT.ConvertStringToNumber(UIT.Value(Library.Door, code[0], Header.E_V)); float Gap = 0; float dt = 0.75f; DoorShow.FromModel(model, 18, 30, dt, ct, E_H, E_V, Gap, code[1]); string displayName; code[1] = UIT.IDCheckExist(Library.CabTexture, code[1]); string color = UIT.Value(Library.CabTexture, code[1], "L" + _G.L); string modelname = UIT.Value(Library.Door, code[0], "L" + _G.L); displayName = modelname + " " + color; Get.o1("GLOBALGPNL/Selections/Door/Name").GetComponent().text = displayName; } public static void Setextfinish(string CODE) { print("Setextfinish CODE===" + CODE); GameObject Finish = Get.o2("GLOBALGPNL/Selections", "Finish"); Finish.SetActive(true); string[] code = CODE.Split('?'); string ColorRecipe = code[0] + "?" + code[1]; Finish.transform.Find("Image").gameObject.GetComponent().sprite = UIT_MATERIAL.GetSprite(ColorRecipe); string ColorUniqueName = UIT.Value(Library.CabTexture, code[0], Header.Unique_Name); Finish.transform.Find("Name").gameObject.GetComponent().text = ColorUniqueName; } public static void SetKick(string CODE) { //print("CODE==kick="+CODE);//Model?Color?Rotation texture Get.o2("GLOBALGPNL/Selections", "Kick").SetActive(true); string[] code = CODE.Split('?'); GameObject IMAGE_SHOW = Get.o2("GLOBALGPNL/Selections/Kick", "IMAGE"); string ColorRecipe = code[1] + "?90"; //Show Kick if (code[0] != "NONE") { IMAGE_SHOW.SetActive(true); Get.o2("GLOBALGPNL/Selections/Kick/IMAGE", "Image").GetComponent().sprite = UIT_MATERIAL.GetSprite(ColorRecipe); //Name string ModelUniqueName = UIT.Value(Library.Molding, code[0], Header.Unique_Name); string ColorUniqueName = UIT.Value(Library.CabTexture, code[1], Header.Unique_Name); Get.o1("Selections/Kick/Name").GetComponent().text = ModelUniqueName + "\n" + ColorUniqueName; } else { IMAGE_SHOW.SetActive(false); Get.o1("Selections/Kick/Name").GetComponent().text = TRANS.This("T_NONE"); } } public static void SetFascia(string CODE) { print("Global CODE==Fascia=" + CODE);//Fascia=NONE?1?90?0 //Global CODE==Fascia=FA_1?FA?90?6 Global CODE==Fascia=G_1 Get.o2("GLOBALGPNL/Selections", "Fascia").SetActive(true); string[] code = CODE.Split('?'); GameObject IMAGE_SHOW = Get.o2("GLOBALGPNL/Selections/Fascia", "IMAGE");//Fascia=FA_1?4?90?6 string ColorRecipe = code[1] + "?90"; //Show Fascia if (code[0] != "NONE") { IMAGE_SHOW.SetActive(true); //Material Mat=UIT_MATERIAL.GetMaterial(ColorRecipe); //MoldingShow.Model_FA_1(6,3,1,Mat); //StaticCoroutine.Start( LibraryCreator.RTImageCaroutine( Get.o2("GLOBALGPNL/Selections/Fascia/IMAGE","RawImage") )); //Get.o2("GLOBALGPNL/Selections/Fascia/IMAGE","RawImage").GetComponent().texture=LibraryCreator.RTImage(); Get.o2("GLOBALGPNL/Selections/Fascia/IMAGE", "Image").GetComponent().sprite = UIT_MATERIAL.GetSprite(ColorRecipe); string ModelUniqueName = UIT.Value(Library.Molding, code[0], Header.Unique_Name); string ColorUniqueName = UIT.Value(Library.CabTexture, code[1], Header.Unique_Name); Get.o1("Selections/Fascia/Name").GetComponent().text = ModelUniqueName + "\n" + ColorUniqueName; } else { IMAGE_SHOW.SetActive(false); Get.o1("Selections/Fascia/Name").GetComponent().text = TRANS.This("T_NONE"); } //Name //Get.o1("GLOBALGPNL/Selections/Fascia/Name").GetComponent().text = code[0]+"/"+code[1]; } public static void SetValance(string CODE) { print("Global CODEE==Valance=" + CODE);//Model?Color?Rotation texture//Global CODEE==Valance=V_1?V?90?2 Get.o2("GLOBALGPNL/Selections", "Valance").SetActive(true); string[] code = CODE.Split('?'); GameObject IMAGE_SHOW = Get.o2("GLOBALGPNL/Selections/Valance", "IMAGE"); string ColorRecipe = code[1] + "?90"; //Show Valance if (code[0] != "NONE") { IMAGE_SHOW.SetActive(true); Get.o2("GLOBALGPNL/Selections/Valance/IMAGE", "Image").GetComponent().sprite = UIT_MATERIAL.GetSprite(ColorRecipe); //Name string ModelUniqueName = UIT.Value(Library.Molding, code[0], Header.Unique_Name); string ColorUniqueName = UIT.Value(Library.CabTexture, code[1], Header.Unique_Name); Get.o1("Selections/Valance/Name").GetComponent().text = ModelUniqueName + "\n" + ColorUniqueName; } else { IMAGE_SHOW.SetActive(false); Get.o1("Selections/Valance/Name").GetComponent().text = TRANS.This("T_NONE"); } //Get.o1("GLOBALGPNL/Selections/Valance/Name").GetComponent().text = code[0]+"/"+code[1]; } public static void SetOgee(string CODE) { print("CODE==Ogee=" + CODE);//Model?Color?Rotation texture Get.o2("GLOBALGPNL/Selections", "Ogee").SetActive(true); string[] code = CODE.Split('?'); GameObject IMAGE_SHOW = Get.o2("GLOBALGPNL/Selections/Ogee", "IMAGE"); string ColorRecipe = code[1] + "?90"; //Show Valance if (code[0] != "NONE") { IMAGE_SHOW.SetActive(true); Get.o2("GLOBALGPNL/Selections/Ogee/IMAGE", "Image").GetComponent().sprite = UIT_MATERIAL.GetSprite(ColorRecipe); //Name string ModelUniqueName = UIT.Value(Library.Molding, code[0], Header.Unique_Name); string ColorUniqueName = UIT.Value(Library.CabTexture, code[1], Header.Unique_Name); Get.o1("Selections/Ogee/Name").GetComponent().text = ModelUniqueName + "\n" + ColorUniqueName; } else { IMAGE_SHOW.SetActive(false); Get.o1("Selections/Ogee/Name").GetComponent().text = TRANS.This("T_NONE"); } // string Tittle=TRANS.This("G_OGEE"); // if(CODE.IndexOf("?")!=-1&& CODE.IndexOf("NONE")==-1 ) { Tittle = Tittle+ " " + DOIT.CSss(code[2]); } // Get.o1("GLOBALGPNL/Selections/Ogee/G_OGEE").GetComponent().text = Tittle; // Get.o2("GLOBALGPNL/Selections/Ogee", "Shadow").SetActive(true); // Get.o1("GLOBALGPNL/Selections/Ogee/Image").GetComponent().enabled = false; // Get.o1("GLOBALGPNL/Selections/Ogee/Image").GetComponent().sprite = null; // GameObject O = Get.o1("GLOBALGPNL/Selections/Ogee/Image"); if (CODE.IndexOf("?") != -1 && CODE.IndexOf("NONE") == -1) { // Material mat; // if(!_G.UIT){ // mat=CREATE.Texture_CAB(code[0], 24, 12, "0", "Ogee","PNL"); // } // else{mat= UIT_MATERIAL.GetMaterial(code[0],"PNL"); } // O.GetComponent().material = mat; // O.GetComponent().material.SetFloat("_rotation", 90); // string colorKey = Get.LibraryValue(code[0], CsvHeaders.Color_ID, DataTypes.Ogee); // string displayName = Get.LibraryValue(colorKey, CsvHeaders.Color, DataTypes.CabTexture) /*+ " " + Get.LibraryValue(colorKey, CsvHeaders.Language, DataTypes.CabTexture)*/; // Get.o1("Selections/Ogee/Name").GetComponent().text = displayName; // string ModelUniqueName=UIT.Value(Library.Molding,code[0],Header.Unique_Name); // string ColorUniqueName=UIT.Value(Library.CabTexture,code[1],Header.Unique_Name); // Get.o1("Selections/Ogee/Name").GetComponent().text = ModelUniqueName+"\n"+ColorUniqueName; } else { //IMAGE_SHOW.SetActive(false); // Get.o2("GLOBALGPNL/Selections/Ogee/", "Shadow").SetActive(false); // O.GetComponent().material = null; // O.GetComponent().sprite = _G.btnX; // O.GetComponent().enabled = true; // Get.o1("GLOBALGPNL/Selections/Ogee/Name").GetComponent().text = TRANS.This("T_NONE"); //Get.o1("Selections/Ogee/Name").GetComponent().text = TRANS.This("T_NONE"); } //Name } public static void SetCounter(string Code) { print("SetCounter code===" + Code);//COUN.1?F6F6F6?F6F6F6?F6F6F6?1?0?0.5?0.3?1 RecipeCountertop = Code; Get.o2("GLOBALGPNL/Selections", "Counter").SetActive(true); ImageCountertop = GameObject.Find("GLOBALGPNL/Selections/Counter/Image"); //ImageCountertop.GetComponent().sprite = UIT_MATERIAL.GetSprite(Code); GameObject.Find("GLOBALGPNL/Selections/Counter/Name").GetComponent().text = Code.Split('?')[0]; Addressables.LoadAssetAsync(Code.Split("?")[0]).Completed +=Texture_Completed_Counter; } public static void SetcaseSplash(string Code) { print("SetcaseSplash===" + Code);//SPLA.17?#F2F7F0?#791C16?#A3A3A3?2?-1?0.9726804?0.2?0.02048972 RecipeSplash = Code; Get.o2("GLOBALGPNL/Selections", "Backsplash").SetActive(true); ImageSplash = GameObject.Find("GLOBALGPNL/Selections/Backsplash/Image"); ImageSplash.GetComponent().sprite = UIT_MATERIAL.GetSprite(Code); GameObject.Find("GLOBALGPNL/Selections/Backsplash/Name").GetComponent().text = Code.Split('?')[0]; Addressables.LoadAssetAsync(Code.Split("?")[0]).Completed += Texture_Completed_Splash; } public static void SetcaseKnob(string path, string G, string sel) { //print("SetcaseKnob code==="+G);//K_54?V?666666_Gloss?6.5625?1?1 //K_54?V?666666_Gloss?6.5625?1?1 //?T?#000000?6.57?0.39?1.10 Get.o2("GLOBALGPNL/Selections", sel).SetActive(true); string Oname; string NameShow; Oname = G.Split('?')[0].Replace("K_", ""); NameShow = G.Split('?')[0]; Sprite S = Resources.Load(path + Oname); GameObject.Find("Selections/" + sel + "/Image").GetComponent().sprite = S; GameObject.Find("Selections/" + sel + "/Name").GetComponent().text = NameShow; } public void CloseGlobalPNL() // used by btnX { DisableDoorImage(); Get.o1("GLOBALGPNL").SetActive(false); } private void DisableDoorImage() { _doorImageCR?.Clear(); //if (_doorImageCR == null) //{ // return; //} // //Material mat = _G.INV; //if (_doorImageCR.GetMaterial() != mat) //{ // _doorImageCR.SetMaterial(mat, null); // Debug.Log("set material door image"); //} } //ADDRESSABLE private static void Texture_Completed_Counter(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { AdressableTextureCounter = Instantiate(handle.Result); StaticCoroutine.Start(AddnewTextureAdressable(ImageCountertop, RecipeCountertop, AdressableTextureCounter)); } } private static void Texture_Completed_Splash(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { AdressableTextureSpash = Instantiate(handle.Result); StaticCoroutine.Start(AddnewTextureAdressable(ImageSplash,RecipeSplash,AdressableTextureSpash)); } } public static IEnumerator AddnewTextureAdressable(GameObject Image, string CodeRecipe, Texture2D T) { yield return new WaitForSeconds(0.15f); string[] Code = CodeRecipe.Split('?'); Color c1 = DOIT.CSc(Code[1], 255); Color c2 = DOIT.CSc(Code[2], 255); Color c3 = DOIT.CSc(Code[3], 255); ModifyTexture.ModifyTexturePixels(T, c1, c2, c3); float R = float.Parse(Code[5]); if (R == 90) { UIT_MATERIAL.RotateTexture(T, R); } Image.GetComponent().sprite = UIT_MATERIAL.TextureToSprite(T); } }