using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System.Collections; using TMPro; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.AddressableAssets; public class TEXTURESPNL : MonoBehaviour { static string _textureCode; static private bool _isBeingModified; static private bool _wasModified; static private TextureChangeCommand _currentCommand; static private string _CodeRecipe; static private Sprite[] _ICONS; static private GameObject _TexturePNL; public TMP_Text _C1; public TMP_Text _C2; public TMP_Text _C3; //public GameObject _Color1; //public GameObject _Color2; public GameObject _Colors; public Slider _TileH; public Slider _TileV; public Slider _Rotation; public Slider _Finish; public Slider _Relief; static private GameObject _ModelContainer; static private GameObject _CATEGORY; static private List _ObjectOnProcess; private static string Category; private static Texture2D AdressableTexture; static GameObject StartImageShow; static GameObject NewImageShow; static Texture2D NewTexture2D; //UNDO REDO----------------------------- private void OnDisable() { if (_isBeingModified && _wasModified && name == "ADD") { _isBeingModified = false; _wasModified = false; StaticCoroutine.Start(CancelChangesOnDisable(_currentCommand)); } } private IEnumerator CancelChangesOnDisable(TextureChangeCommand command) { yield return null; command.Undo(); } static public void UpdateTexture(string textureCode) { // _wasModified = true; // _textureCode = textureCode; // if (_G.texturesStart.Count > 0) // { // _currentCommand = new TextureChangeCommand(_G.PNL, _G.texturesStart, textureCode); // } // else // { // _currentCommand = new TextureChangeCommand(_G.PNL, _G.TCsStart, textureCode); // } // _currentCommand.Execute(); } //START PANEL------------------------------------------------------------------------ public void StartPNL(string name) { //("Name====="+name); Startpnl(name); } public static void Startpnl(string name) { //ObjectOnPrecess.Clear(); if (SceneModeManager.SelectedName.IndexOf("bloc") != -1) { name = "BLOC"; } _TexturePNL = Get.o2("Panel_SCENE/PNL", "TEXTUREPNL"); _ModelContainer = Get.o2("Panel_SCENE/PNL/TEXTUREPNL/LARGE/MODEL/Viewport", "Content"); _G.SC[0] = ""; _ObjectOnProcess = new(); DOIT.CloseALLPNLONLY(); _isBeingModified = true; _wasModified = false; //print("Start name==="+name); _TexturePNL.SetActive(true); _G.PON = "TEXTUREPNL"; SetPanel.Large(); SceneModeManager.Instance.SetSceneMode(SceneModes.Panel); //Add library _CATEGORY = Get.o2("Panel_SCENE/PNL/TEXTUREPNL/LARGE/", "CATEGORY"); DOIT.DELETEAllObjectChild(_CATEGORY); AddBTNCAT("T_counter"); // changes based on the number of entry AddBTNCAT("T_wood"); // changes based on the number of entry AddBTNCAT("T_Ceramic"); // changes based on the number of entry AddBTNCAT("T_Brick"); // changes based on the number of entry AddBTNCAT("T_Splash"); // changes based on the number of entry Set.ToggleGroupToAllChild("TEXTUREPNL/LARGE/CATEGORY"); float posY = 0; if (name == "FLOOR") { _G.PNL = "TexturesFloorPNL"; posY = 97; } else if (name == "BLOC") { _G.PNL = "TexturesBlocPNL"; } else if (name == "WALL" || name == "AWAL") { _G.PNL = "TexturesWallPNL"; } else if (name == "Splash") { _G.PNL = "TexturesSplashPNL"; } else if (name == "Counter") { _G.PNL = "TexturesCounterPNL"; } else if (name == "Deco") { _G.PNL = "TexturesDecoPNL"; } _TexturePNL.transform.localPosition = new Vector3(0, posY, 0); _G.TCsStart = GetStartCode(); ShowTextureStart(); SetStartbyCategory(name); //ResetSliderColor(); Get.o2("Canvas/Panel_SCENE/PNL/TEXTUREPNL/LARGE", "VisualiserBtn").SetActive(_G.PATH == "laminam"); } public void StartPanelForWall() { //print("PAINT.SEL ===" + PAINT.SEL); bool isSingleWall = PAINT.SEL == "ceil" || Get.o1(PAINT.SEL + "/s1") != null; if (isSingleWall || PAINT.SEL == "AWAL") { Get.o1("Canvas/Panel_SCENE/PNL").transform.Find("PAINTpnl").gameObject.SetActive(false); string wallCode = isSingleWall ? "WALL" : "AWAL"; StartPNL(wallCode); } //Message if nothing selected else { _M.PH(14, 175, "ffffff", 1, 1); } } public static void AddBTNCAT(string CATEGORY) { string caterogyTranslation = TRANS.This(CATEGORY); GameObject Cat = Instantiate(GameObject.Find("TEXTUREPNL").transform.Find("BTNCATEGORY").gameObject); Cat.transform.SetParent(Get.o1("TEXTUREPNL/LARGE/CATEGORY").transform, false); Cat.transform.Find("Background").transform.Find("Text").gameObject.GetComponent().text = caterogyTranslation; Cat.SetActive(true); CATEGORY = GetCat(CATEGORY); Cat.name = CATEGORY; //Cat.GetComponent().onValueChanged.AddListener(delegate { ShowSelections(CATEGORY, qty); }); } public static void AddBTNSELECTION(int i, string Category)//GET ICON FOR THAT BUTTON { //print("Category====="+Category); GameObject Sel = Instantiate(GameObject.Find("TEXTUREPNL").transform.Find("BTNSELECTION").gameObject); Sel.name = Category + "." + i.ToString(); //print("Category=====path==="+"ICONS/TEXTURES/"+Category+"/"+Sel.name); Sel.transform.Find("Background").GetComponent().sprite = GetIconbyOrder(Sel.name);//_ICONS[i-1];//Resources.Load("ICONS/TEXTURES/"+Category+"/"+Sel.name ); Sel.transform.SetParent(_ModelContainer.transform, false); Sel.transform.Find("Image").transform.Find("Text").gameObject.GetComponent().text = Sel.name; Sel.SetActive(true); } public static Sprite GetIconbyOrder(string IconName) { for (int i = 0; i < _ICONS.Length; i++) { if (_ICONS[i].name == IconName) return _ICONS[i]; } return _ICONS[0]; } //SELECTIONS------------------------------- public static void ShowSelections() { Category = Get.TogOn(_CATEGORY).name; DOIT.DELETEAllObjectChild(_ModelContainer); _ICONS = Resources.LoadAll("ICONS/TEXTURES/" + Category); for (int i = 1; i < _ICONS.Length + 1; i++) { AddBTNSELECTION(i, Category); } Set.ToggleGroupToAllChild("TEXTUREPNL/LARGE/MODEL/Viewport/Content"); } public void ShowSelected() { //ResetSliderColor(); _G.SC[0] = Get.TogOn(_ModelContainer).name; _CodeRecipe = GetCodeRecipe(); _G.TCsNew = _CodeRecipe; AddNewTexture(_CodeRecipe); Get.o2("TEXTUREPNL", "Editing").GetComponent().isOn = false; GameObject PresetsColors = Get.o2("TEXTUREPNL", "PresetAllColors"); Set.alpha(PresetsColors, true); Set.alpha(Get.o2("TEXTUREPNL", "COLORS"), false); PresetColor.SetPreset(Category, _G.SC[0]); PresetsColors.transform.GetChild(0).gameObject.GetComponent().isOn=true; PresselColorChange(); } public void ColorChange() { _CodeRecipe = GetCodeRecipe(); print("_CodeRecipe=====" + _CodeRecipe);// //WOOD.1?#E9E1C6?#925E47?#909090?1-1?0?0.5?0.1666667?0 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); foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material.SetColor("_c1", c1); O.GetComponent().material.SetColor("_c2", c2); O.GetComponent().material.SetColor("_c3", c3); } Texture2D T = Instantiate(NewTexture2D); ModifyTexture.ModifyTexturePixels(T, c1, c2, c3); NewImageShow.GetComponent().sprite = UIT_MATERIAL.TextureToSprite(T); _G.TCsNew = _CodeRecipe; } public void PresselColorChange() { string PresetBtnNumber = Get.TogOn(Get.o2("TEXTUREPNL", "PresetAllColors")).name; string NamePreset = Category + "_" + PresetBtnNumber; print("name====" + NamePreset); string[] C = PresetRecipe.Textures[NamePreset].Split("_"); _C1.text = C[1]; _C2.text = C[2]; _C3.text = C[3]; _CodeRecipe = GetCodeRecipe(); print("_CodeRecipe=====" + _CodeRecipe);// //WOOD.1?#E9E1C6?#925E47?#909090?1-1?0?0.5?0.1666667?0 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); foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material.SetColor("_c1", c1); O.GetComponent().material.SetColor("_c2", c2); O.GetComponent().material.SetColor("_c3", c3); } Texture2D T = Instantiate(NewTexture2D); ModifyTexture.ModifyTexturePixels(T, c1, c2, c3); NewImageShow.GetComponent().sprite = UIT_MATERIAL.TextureToSprite(T); _G.TCsNew = _CodeRecipe; Get.o2("TEXTUREPNL/SLIDERS", "SliderFinish").GetComponent().value = float.Parse(C[4]); } //SETTING------------------------------- public void GroutSet() { // bool isColor2=true; // if (Category=="WOOD"){ isColor2=true;} // _Color2.SetActive(isColor2); } public static void SetStartbyCategory(string name) { _CATEGORY.transform.Find("WOOD").GetComponent().isOn = true; print("name=======================" + name); Category = "CERA"; switch (name) { case "FLOOR": Category = "CERA"; break; case "Counter": Category = "COUN"; break; case "WALL": Category = "BRIC"; break; case "AWAL": Category = "BRIC"; break; case "Splash": Category = "SPLA"; break; case "Deco": Category = "WOOD"; break; case "BLOC": Category = "COUN"; break; } _CATEGORY.transform.Find(Category).GetComponent().isOn = true; ShowSelections(); } public void SetFinish() { foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material.SetFloat("_Smoothness", _Finish.value); float Metalness = _Finish.value / 3; O.GetComponent().material.SetFloat("_Metalness", Metalness); //ColorChange(); } } public void SetRotation() { foreach (GameObject O in _ObjectOnProcess) { _G.TCsNew = GetCodeRecipe(); O.GetComponent().material.SetFloat("_Rotation", _Rotation.value); } } public void SetSize() { foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material.SetVector("_Tile", new(2 - _TileH.value, 2 - _TileV.value)); } } public void SetRelief() { foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material.SetFloat("_Relief", _Relief.value); } } public static void Setsliders() { float Size = 9 - float.Parse(_G.SC[1]); if (_G.SC[5] == "NA") { _G.SC[5] = "0.5"; } _G.SC[6] = _G.SC[6].Replace("r", ""); if (_G.SC[7].IndexOf("G") != -1) { _G.SC[7] = "0.95"; } if (_G.SC[7].IndexOf("S") != -1) { _G.SC[7] = "0.8"; } if (_G.SC[7].IndexOf("M") != -1) { _G.SC[7] = "0.5"; } float R = float.Parse(_G.SC[6]) / 15; Get.o1("TEXTUREPNL/SLIDERS/SliderSize").GetComponent().value = Size;//Size //Get.o1("TEXTUREPNL/SLIDERS/SliderContrast").GetComponent().value = float.Parse(_G.SC[2]);//Contrast //Get.o1("TEXTUREPNL/SLIDERS/SliderGrouthSize").GetComponent().value = float.Parse(_G.SC[5]);//Grove Get.o1("TEXTUREPNL/SLIDERS/SliderRotation").GetComponent().value = R;//Rotation //Get.o1("TEXTUREPNL/SLIDERS/SliderFinish").GetComponent().value = float.Parse(_G.SC[7]);//Finish //Get.o1("TEXTUREPNL/SLIDERS/SliderGroutIntensity").GetComponent().value = float.Parse(_G.SC[9]);//Intensity } public static void ResetSliderColor() { Get.o2("TEXTUREPNL/COLORS/ColorPickerDeco1", "Slider").GetComponent().value = 0; Get.o2("TEXTUREPNL/COLORS/ColorPickerDeco2", "Slider").GetComponent().value = 0.9f; Get.o2("TEXTUREPNL/COLORS/ColorPickerDeco3", "Slider").GetComponent().value = 0.5f; } //ADDING------------------------------ public void Add() { string NewCode= GetCodeRecipe(); if (_G.TCsNew != NewCode) { AddNewTexture(NewCode); _G.TCsNew = NewCode; } if (_G.PNL == "TexturesFloorPNL") { _G.FLCs = _G.TCsNew; CreateFloor.SetFloor(); ConstructOpen.RedrawOpen(); } else if (_G.PNL == "TexturesCounterPNL") { //print("-----Add()------" + GetCodeRecipe()); if (_P.List["GLOBAL_QTY"] == "0") { SELECTMETHODE(_G.TCsNew); } else { UIT.GlobalSet(Header.Counter, _G.TCsNew, _G.G); DOIT.AddtoCodeCabGlobal(41, _G.TCsNew, _G.G); } } else if (_G.PNL == "TexturesWallPNL") { //UIT.GlobalSet(Header.Counter,GetCodeRecipe(),_G.G); //print("-----Add()------"+GetCodeRecipe()); } else if (_G.PNL == "TexturesSplashPNL") { UIT.GlobalSet(Header.Splash, _G.TCsNew, _G.G); DOIT.AddtoCodeCabGlobal(54, _G.TCsNew, _G.G); } else if (_G.PNL == "TexturesBlocPNL") { //print("pass TexturesBlocPNL======"+GetCodeRecipe()); int ind = Get.GetObjectIndex(SceneModeManager.SelectedName); _G.OBJs[ind][41] = _G.TCsNew; } else if (_G.PNL == "TexturesDecoPNL") { int ind = Get.GetObjectIndex(SceneModeManager.SelectedName); if (_G.OBJs[ind][2] == "Bloc") { _G.OBJs[ind][41] = _G.TCsNew; } else { _G.OBJs[ind][60] = _G.TCsNew; } } _isBeingModified = false; if (_wasModified) { _wasModified = false; CommandHandler.Instance.AddToHistory(_currentCommand); } if (gameObject.activeInHierarchy) { DOIT.CloseALLPNL(); } } public void ExitPNL() { //print("From exit ===="+_G.TCsStart); foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material = UIT_MATERIAL.GetMaterial(_G.TCsStart); Addressables.LoadAssetAsync(_G.TCsStart.Split("?")[0]).Completed += Texture_Completed; StartCoroutine(AddnewTextureAdressable()); } _isBeingModified = false; if (_wasModified) { _wasModified = false; _currentCommand.Undo(); } DOIT.CloseALLPNL(); } public static void AddNewTexture(string NewCode) { //print("NewCode===="+NewCode);//NewCode====?New Text?New Text?#737373?1?0?0.5?0.6?0 Material Mat = UIT_MATERIAL.GetMaterial(NewCode); foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material = Mat; } _G.TCsNew=_G.TCsNew.Replace(",","?"); Addressables.LoadAssetAsync(_G.TCsNew.Split("?")[0]).Completed += Texture_Completed; //StaticCoroutine.Start(AddnewTextureAdressable()); } private static IEnumerator AddnewTextureAdressable() { yield return new WaitForSeconds(0.15f); foreach (GameObject O in _ObjectOnProcess) { O.GetComponent().material.SetTexture("_Texture", AdressableTexture); } } public static void SELECTMETHODE(string code) { int GG = 1; UIT.GlobalSet(Header.Counter, code, GG); List CabinetsToModify = Get.CabinetsToModifyInt(); foreach (int Ind in CabinetsToModify) { _G.OBJs[Ind][41]= code; } DOIT.REDOALLCab_GNum(GG); DOIT.CloseALLPNL(); DOIT.AllSelOff(); } //GET---------------------------------- public static string GetStartCode() { print("_G.PNL======"+_G.PNL);//_G.PNL======TexturesBlocPNL if (_G.PNL == "TexturesWallPNL") { Material MAT; if (PAINT.SEL == "ceil") { MAT = Get.o2(PAINT.SEL, "s1").GetComponent().material; for (int i = 0; i < _G.CeilingPoints.Length; i++) { Get.o1("s" + PAINT.SEL + i.ToString()).GetComponent().material = _G.INV; } _G.TCsStart = TextureCall.getcodeTextureFromMat(MAT); _ObjectOnProcess.Add(Get.o2(PAINT.SEL, "s1")); } else if (PAINT.SEL == "AWAL") // { for (int i = 0; i < _G.NW; i++) { string key = "w" + (i + 1).ToString(); GameObject wall = Get.o1(key); if (wall == null) { continue; } foreach (Transform sWall in wall.transform) { MAT = sWall.GetComponent().material; _G.TCsStart = TextureCall.getcodeTextureFromMat(MAT); _ObjectOnProcess.Add(sWall.gameObject); } Get.o1(key.Replace("w", "m")).GetComponent().material = _G.INV; } } else { GameObject wall = Get.o1(PAINT.SEL); foreach (Transform sWall in wall.transform) { MAT = sWall.GetComponent().material; _G.TCsStart = TextureCall.getcodeTextureFromMat(MAT); _ObjectOnProcess.Add(sWall.gameObject); } Get.o1(PAINT.SEL.Replace("w", "m")).GetComponent().material = _G.INV; } } if (_G.PNL == "TexturesBlocPNL") { int ind = Get.GetObjectIndex(SceneModeManager.SelectedName); _G.TCsStart = _G.OBJs[ind][41]; GameObject Bloc = Get.o1(SceneModeManager.SelectedName); _ObjectOnProcess.Add(Bloc.transform.Find("top").gameObject); _ObjectOnProcess.Add(Bloc.transform.Find("front").gameObject); _ObjectOnProcess.Add(Bloc.transform.Find("left").gameObject); _ObjectOnProcess.Add(Bloc.transform.Find("back").gameObject); _ObjectOnProcess.Add(Bloc.transform.Find("right").gameObject); _ObjectOnProcess.Add(Bloc.transform.Find("under").gameObject); Bloc.GetComponent().material = _G.INV; } if (_G.PNL == "TexturesFloorPNL") { _G.TCsStart = _G.FLCs; _ObjectOnProcess.Add(Get.o2("ROOM", "floor")); } if (_G.PNL == "TexturesSplashPNL" && SceneModeManager.SelectedName == "") { _G.TCsStart = UIT.Global(Header.Splash, _G.G); GameObject[] objectsWithTag = GameObject.FindGameObjectsWithTag("splash"); _ObjectOnProcess = new List(objectsWithTag); } if (_G.PNL == "TexturesSplashPNL" && SceneModeManager.SelectedName != "") { int nO = Get.GetObjectIndex(SceneModeManager.SelectedName); _G.TCsStart = _G.OBJs[nO][54]; } if (_G.PNL == "TexturesCounterPNL") { _G.TCsStart = UIT.Global(Header.Counter, _G.G); List CabinetsToModify = Get.CabinetsToModifyInt(); List ObjectToModify = new(); foreach(int ind in CabinetsToModify) { print("ind======================" + ind); GameObject Cabinet = Get.o2("SCENE", _G.OBJs[ind][0]); if (Cabinet.transform.Find("CABCOUNTER")!=null) { Transform CabinetCounter = Cabinet.transform.transform.Find("CABCOUNTER").transform; foreach(Transform obj in CabinetCounter.transform) { ObjectToModify.Add(obj.gameObject); } } } foreach (GameObject O in ObjectToModify) { //Find if Global number string ParentName = O.transform.parent.parent.name; int Global = _G.G; //if cabinet if (ParentName.IndexOf("cabi") != -1) { int ADN = Get.GetObjectIndex(O.transform.parent.parent.name); if (_G.OBJs[ADN][60] != "UNIQUE" && !_AI.On) { Global = int.Parse(_G.OBJs[ADN][60].Replace("GLOBAL", "")); if (Global == _G.G) { _ObjectOnProcess.Add(O); } } if (_AI.On) { _ObjectOnProcess.Add(O); } } if (O.transform.parent.name.IndexOf("bloc") != -1) { _ObjectOnProcess.Add(O); } if (ParentName.IndexOf("dish") != -1) { int ADN = Get.GetObjectIndex(O.transform.parent.parent.name); if (_G.OBJs[ADN][60] != "UNIQUE" && !_AI.On) { Global = int.Parse(_G.OBJs[ADN][60].Replace("GLOBAL", "")); if (Global == _G.G) { _ObjectOnProcess.Add(O); } } if (_AI.On) { _ObjectOnProcess.Add(O); } } if (ParentName.IndexOf("wine") != -1) { int ADN = Get.GetObjectIndex(O.transform.parent.parent.name); if (_G.OBJs[ADN][60] != "UNIQUE") { Global = int.Parse(_G.OBJs[ADN][60].Replace("GLOBAL", "")); if (Global == _G.G) { _ObjectOnProcess.Add(O); } } } } } if (_G.PNL == "TexturesDecoPNL") { int ind = Get.GetObjectIndex(SceneModeManager.SelectedName); _G.TCsStart = _G.OBJs[ind][60]; GameObject Deco = Get.o1(SceneModeManager.SelectedName); _ObjectOnProcess.Add(Deco.transform.Find("S1").gameObject);//Table //ewCode====?New Text?New Text?New Text?1?0?0.5?0.2?0 Deco.GetComponent().material = _G.INV; } return _G.TCsStart; } public static void ShowTextureStart() { //_G.TCsStart====none,#737373,#ffffffff,#ffffffff,1,0,0.1,0.05 StartImageShow = Get.o2("Canvas/Panel_SCENE/PNL/TEXTUREPNL", "StartImage"); StartImageShow.GetComponent().sprite = UIT_MATERIAL.GetSprite(_G.TCsStart); _G.TCsStart = _G.TCsStart.Replace(",", "?"); print("_G.TCsStart====" + _G.TCsStart);//_G.TCsStart====none?#737373?#ffffffff?#ffffffff?1?0?0.1?0.05 if (_G.TCsStart.Split("?")[0] != "none" && _G.TCsStart.Split("?").Length > 3) { Addressables.LoadAssetAsync(_G.TCsStart.Split("?")[0]).Completed += Start_Texture_Show_Completed; } _G.TCsNew = _G.TCsStart; ShowTextureNew(); } public static void ShowTextureNew() { NewImageShow= Get.o2("Canvas/Panel_SCENE/PNL/TEXTUREPNL", "NewImage"); NewImageShow.GetComponent().sprite = UIT_MATERIAL.GetSprite(_G.TCsNew); _G.TCsNew = _G.TCsNew.Replace(",", "?"); print("_G.TCsNew=====================" + _G.TCsNew); if (_G.TCsNew.Split("?")[0] != "none" && _G.TCsNew.Split("?").Length>3) { Addressables.LoadAssetAsync(_G.TCsNew.Split("?")[0]).Completed += New_Texture_Show_Completed; } } public static string GetCat(string name) { switch (name) { case "T_wood": return "WOOD"; case "T_Ceramic": return "CERA"; case "Vini": return "VINY"; case "T_Splash": return "SPLA"; case "T_Brick": return "BRIC"; case "T_counter": return "COUN"; default: Debug.Log("No Category correspond to " + name); return ""; } } public string GetCodeRecipe() { print("Texture===" + _G.SC[0]); if (string.IsNullOrEmpty(_G.SC[0])) { _G.SC[0] = _G.TCsNew.Split("?")[0]; } string TextureName = _G.SC[0]; string Tile = (2 - _TileH.value).ToString() + "-" + (2 - _TileV.value).ToString();// "1_1"; string Rotation = _Rotation.value.ToString(); string Smoothness = _Finish.value.ToString(); string Metallic = (_Finish.value / 3).ToString(); float Relief = _Relief.value; string Contrast = "1"; print("_C1====" + _C1.text); if (string.IsNullOrEmpty(_C1.text) || _C1.text=="New Text") { _C1.text = _G.TCsStart.Split("?")[1]; _C2.text = _G.TCsStart.Split("?")[2]; _C3.text = _G.TCsStart.Split("?")[3]; } if (_G.PNL == "TexturesFloorPNL") { //Metallic="0.6"; } List ListCode = new() { TextureName, _C1.text, _C2.text, _C3.text, Tile, Rotation, Contrast, Smoothness, Metallic, Relief.ToString() }; string NewCode = ""; for (int i = 0; i < ListCode.Count; i++) { NewCode += ListCode[i]; if (i < ListCode.Count - 1) NewCode += "?"; } //_G.TCsNew = NewCode; return NewCode; } public string DarkenHexColor(string hexColor, float darkenFactor) { // Parse the hex string to a Color object if (ColorUtility.TryParseHtmlString(hexColor, out Color color)) { // Darken the color by multiplying RGB values by the darkenFactor color.r *= darkenFactor; color.g *= darkenFactor; color.b *= darkenFactor; // Clamp to ensure values are still within 0 to 1 range color.r = Mathf.Clamp01(color.r); color.g = Mathf.Clamp01(color.g); color.b = Mathf.Clamp01(color.b); // Convert the darkened color back to hex return ColorUtility.ToHtmlStringRGB(color); } Debug.LogWarning("Invalid Hex Color"); return null; } //ADDRESSABLE private static void Texture_Completed(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { AdressableTexture = Instantiate(handle.Result); ShowTextureNew(); StaticCoroutine.Start(AddnewTextureAdressable()); } } private static void Start_Texture_Show_Completed(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { StaticCoroutine.Start(AddnewTextureAdressable(StartImageShow, _G.TCsStart, Instantiate(handle.Result))); } } private static void New_Texture_Show_Completed(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { NewTexture2D = Instantiate(handle.Result); StaticCoroutine.Start(AddnewTextureAdressable(NewImageShow, _G.TCsNew, Instantiate(handle.Result))); if(Get.o2("Panel_SCENE/PNL","TEXTUREPNL")!=null && Get.o2("Panel_SCENE/PNL","TEXTUREPNL").activeInHierarchy){ResetSliderColor();} } } 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); } }