using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; using petabytes.LTCLight; public class ModifyObjectColor : MonoBehaviour { public GameObject ModifyPNL; public Text _Tittle; public TMP_Dropdown _CABTEXTURES; public Image _Preview1; public Image _Preview2; public TMP_Dropdown _Finish1; public TMP_Dropdown _Finish2; public TMP_Text _C1; public TMP_Text _C2; public GameObject _Color1; public GameObject _Color2; public GameObject _TextureBtn; public GameObject _Rotation; public GameObject _MirrorSetting; public Slider _MirrorBackLightSlider; public Slider _MirrorLineLightSlider; public TMP_InputField _MirrorBorderWide; private string Category; public void StartPnl(){ _G.nO = Get.GetObjectIndex(SceneModeManager.SelectedName); Category=""; if (new List { "HOOW", "HOOC"}.Contains(Category))return; _Tittle.text=_G.OBJs[_G.nO][1]; if(_G.OBJs[_G.nO][1].Length>4){Category=_G.OBJs[_G.nO][1][..4];} if (new List { "BLOC", "TABL", "CHAI", "STOO", "VASE", "SMAL", "PICT", "MIRR", "LAMP", "TOIL", "BATH", "SHAW", "ORNA" ,"DOOS", "DOOD", "DOWS", "DOWD"}.Contains(Category)) { StartPnlbyCategory(); } } public void StartPnlbyCategory(){ DOIT.CloseALLPNLONLY(); Category=_G.OBJs[_G.nO][1][..4]; _Tittle.text=_G.OBJs[_G.nO][1]; ModifyPNL.SetActive(true); ModifyPNL.transform.localPosition = new(0, 0, 0); FillFinishDropdown(_Finish1); _Rotation.SetActive(false); _MirrorSetting.SetActive(false); _CABTEXTURES.gameObject.SetActive(false); _TextureBtn.SetActive(false); if (Category == "BLOC") { AddCabtextureToPnl(); _Rotation.SetActive(true); } if(Category == "MIRR") { _MirrorSetting.SetActive(true); _CABTEXTURES.gameObject.SetActive(false); } if(new List {"BLOC","TABL","CHAI","STOO"}.Contains(Category)) { _TextureBtn.SetActive(true); } SetColorPickerShow(); } //Setting public void SetColorPickerShow() { bool isColor2=true; switch(Category) { case "BLOC":isColor2=false;break; case "TABL":isColor2=false;break; case "VASE":isColor2=false;break; case "MIRR":isColor2=false;break; case "HOOW":isColor2=false;break; case "HOOC":isColor2=false;break; } if(_Tittle.text=="TABL108" || _Tittle.text=="TABL109" ){isColor2=true;} _Color2.SetActive(isColor2); if(isColor2){FillFinishDropdown(_Finish2);} } public void ColorFromObjectToPicker(){ } // public void SetTextureIcon(){ // bool isTextureAvailable=false; // if(new List {"BLOC","TABL","CHAI","STOO"}.Contains(Category)){ // isTextureAvailable=true; // } // _TextureBtn.gameObject.SetActive(isTextureAvailable); // } public void CabTexturesSelect(){ if(_CABTEXTURES.value==0){ //_FINISH1.SetActive(true); //_Preview1.GetComponent().sprite=null; //_Texture1.value=0; } else { // _FINISH1.SetActive(false); // _Preview1.GetComponent().sprite=UIT_MATERIAL.GetSprite(GetIDfromDropCabtextures()); // _Preview1.GetComponent().color=Color.white; } } public void AddCabtextureToPnl(){ _CABTEXTURES.gameObject.SetActive(true); List CabTextureList= new(){TRANS.This("T_Custom") }; List L=UIT.GetLibrary("CabTexture"); for(int i=1; i(); Drop.ClearOptions(); Drop.AddOptions(CabTextureList); } public void TextureSelection(string Name){ // if(Name=="Texture1"){ // int Value=_Texture1.value; // Texture2D T=null; // switch (Value){ // case 3:T=_G.Wood[0];break; // case 4:T=_G.Wood[1];break; // case 5:T=_G.Wood[2];break; // case 6:T=_G.Fabric[0];break; // case 7:T=_G.Fabric[1];break; // } // if(T!=null){_Preview1.sprite=UIT_MATERIAL.TextureToSprite(T);} // else {_Preview1.sprite=null;} // } } //Color Change public void ChangeColorOnObject(){ print("Value==="+transform.GetComponent().value); print("Color1==="+_Color1.GetComponent().text); } //Finish public void FillFinishDropdown(TMP_Dropdown _Finish){ if(_Finish.options.Count==1){ _Finish.ClearOptions(); List list = new(){ TRANS.This("T_Matt"),TRANS.This("T_Semi"),TRANS.This("T_Gloss") }; _Finish.AddOptions(list); } } //public void FillTexturesDropdown(){ // if(_Texture1.options.Count==1){ // _Texture1.ClearOptions(); // List list = new List(){ // TRANS.This("T_Plastic"),TRANS.This("T_Metal"),TRANS.This("T_Paint"), // TRANS.This("T_Woodlight"),TRANS.This("T_Woodmedium"),TRANS.This("T_Woodold"), // TRANS.This("T_Fabric")+" 1",TRANS.This("T_Fabric")+" 2", // }; // _Texture1.AddOptions(list); // } // } public string GetIDfromDropCabtextures(){ int Value=_CABTEXTURES.value; string UniqueName=_CABTEXTURES.options[Value].text; string ID=UIT.GetIDByUnique_Name(Library.CabTexture,UniqueName); return ID; } //Add to Object public void AddNewTexture() { string Category=_G.OBJs[_G.nO][1][..4]; int index1=60; int index2=61; switch (Category){ case "BLOC":index1=41; break; case "TABL":index1=60; break; case "HOOW":index1=61; break; case "HOOC":index1=61; break; } if(new List {"DOOS", "DOOD", "DOWS", "DOWD" }.Contains(Category)) { _G.OBJs[_G.nO][62]=GetColor(_C1.text,_Finish1);//Color door _G.OBJs[_G.nO][63]=GetColor(_C2.text,_Finish2); } else if(new List {"HOOW", "HOOC" }.Contains(Category)) { _G.OBJs[_G.nO][index1]=GetColor(_C1.text,_Finish1); } else { _G.OBJs[_G.nO][index1]=GetColor(_C1.text,_Finish1); _G.OBJs[_G.nO][index2]=GetColor(_C2.text,_Finish2); } if (_CABTEXTURES.isActiveAndEnabled && _CABTEXTURES.value != 0) { _G.OBJs[_G.nO][index1] = GetIDfromDropCabtextures() + "?0";//ID } if(Category=="BLOC"){_Add.Texture(_G.OBJs[_G.nO][index1]);} DOIT.REDOOBJECT(_G.nO); DOIT.CloseALLPNL(); } //Selection---------------------------------------------------- // public void ShowColortoObject(string Name){ // //Find wicht color 1 or 2 // print("Name===="+Name); // if(Name=="Picker1"){print("HEx color ===="+_C1.text);} // if(Name=="Picker2"){print("HEx color ===="+_C2.text);} // //Find the color Object // print("Color1==="+_G.OBJs[_G.nO][60]);//#DBBE92FF_Matt_FLAT // print("Color2==="+_G.OBJs[_G.nO][61]); // string HexColor=_G.OBJs[_G.nO][60].Split(",")[0]; // Get.o2(_G.OBJs[_G.nO][0]+"/S1","Stool_101_C1").GetComponent().material.SetColor("_c1",DOIT.CSc(HexColor,255)); // } // //Get------------------------------------- public string GetColor(string Hex,TMP_Dropdown Finish){ return Hex+"_"+Finish.options[Finish.value].text+"_FLAT"; } public void RotateTexture(){ int ADN=Get.GetObjectIndex(SceneModeManager.Selected.name); //BRIC.18?#ffffff?#000000?#FFFFFFFF?1?25?0.5?0.2?0 print("_G.OBJs[ADN][41]===="+_G.OBJs[ADN][41]); if(_G.OBJs[ADN][41].Split('?').Length>5) { if(_G.OBJs[ADN][41].Split("?")[5]=="0") { _G.OBJs[ADN][41]=Get.ChangeOnStringPos(_G.OBJs[ADN][41], "90", 5, "?"); } else { _G.OBJs[ADN][41]=Get.ChangeOnStringPos(_G.OBJs[ADN][41], "0", 5, "?"); } } else { if(_G.OBJs[ADN][41].Split('?').Length==1)_G.OBJs[ADN][41]+="?0"; if(_G.OBJs[ADN][41].Split('?')[1]=="0")_G.OBJs[ADN][41]=_G.OBJs[ADN][41].Replace("0","90"); else{_G.OBJs[ADN][41]=_G.OBJs[ADN][41].Replace("90","0");} } DOIT.REDOOBJECT(_G.nO); DOIT.CloseALLPNL(); } //Mirror public void MirrorBackLight() { float Value=_MirrorBackLightSlider.value; print("Mirror---MirrorBackLight----"+Value); _G.nO = Get.GetObjectIndex(SceneModeManager.SelectedName); GameObject O = Get.o2("SCENE",SceneModeManager.SelectedName); int ADN=Get.GetObjectIndex(O.name); string MirrorModel=_G.OBJs[ADN][1]; O.transform.Find("Mirror/"+MirrorModel+"/MirrorGlass").GetComponent().Intensity = new(1f,Value); _G.OBJs[ADN][62]="BackLight?"+Value.ToString(); } public void MirrorLineLight() { float Value=_MirrorLineLightSlider.value; print("Mirror----MirrorBorder----"+Value); _G.nO = Get.GetObjectIndex(SceneModeManager.SelectedName); GameObject O = Get.o2("SCENE",SceneModeManager.SelectedName); int ADN=Get.GetObjectIndex(O.name); string MirrorModel=_G.OBJs[ADN][1]; LineRenderer lr=O.transform.Find("Mirror/"+MirrorModel+"/LineGlass").GetComponent(); lr.startWidth = Value; lr.endWidth = Value; _G.OBJs[ADN][63]="LineLight?"+Value.ToString(); } public void MirrorBorder() { string Value=_MirrorBorderWide.text; int ADN=Get.GetObjectIndex(SceneModeManager.SelectedName); _G.OBJs[ADN][11]=Value.ToString(); print("Mirror----MirrorBorder----"+Value); } }