using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; 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; private string Category; public void StartPnl(){ _G.nO = Get.GetObjectIndex(SceneModeManager.SelectedName); Category=""; _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" }.Contains(Category)) { ModifyPNL.SetActive(true); ModifyPNL.transform.localPosition = new(0, 0, 0); FillFinishDropdown(_Finish1); //FillTexturesDropdown(); if (Category == "BLOC") { AddCabtextureToPnl(); _Rotation.SetActive(true); } else { _CABTEXTURES.gameObject.SetActive(false); _Rotation.SetActive(false); } SetColorPickerShow(); SetTextureIcon(); } } //Setting public void SetColorPickerShow() { bool isColor2=true; print("Category===="+Category);//Category====TABL switch(Category) { case "BLOC":isColor2=false;break; case "TABL":isColor2=false;break; case "VASE":isColor2=false;break; case "MIRR":isColor2=false;break; } print("_Tittle.text===="+_Tittle.text); if(_Tittle.text=="TABL108" || _Tittle.text=="TABL109" ){isColor2=true;} print("isColor===="+isColor2); _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; } _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(); } }