using TMPro; using UnityEngine; using UnityEngine.UI; public class SliderColor : MonoBehaviour { static public bool ignoreTextureChange; public Slider sliderSelect; public Slider sliderColorAdd; public Image _bacgroundGrayScale; public Image _ShowColor; public Image _bacgroundColor; public Slider _sliderColor; public Slider _sliderIntensity; // public void Changing() // { // int colorvalue = Mathf.RoundToInt(128 * sliderSelect.value / 44); // Color pickColor = _bacgroundColor.GetComponent().sprite.texture.GetPixel(colorvalue, 0); // _bacgroundGrayScale.transform.GetComponent().material.SetColor("_Color", pickColor); // if (this.name == "SliderSelectColor") colorselect(); // if (this.name == "SliderColorGrout") Groove(); // } // public void Groove() // { // //print("SliderColorGrout.value==="+sliderColorAdd); // float saturation = sliderColorAdd.value; // Color col = bacgroundGrayScale.GetComponent().material.GetColor("_Color"); // float H, S, V; // Color.RGBToHSV(col, out H, out S, out V); // Color actColor = Color.HSVToRGB(H, saturation, V); // _G.SC[4] = ColorUtility.ToHtmlStringRGB(actColor); // SetOntarget(); // } // public void colorselect() // { // //print("sliderColorAdd.value==="+sliderColorAdd.value); // float saturation = sliderColorAdd.value; // Color col = _bacgroundGrayScale.GetComponent().material.GetColor("_Color"); // float H, S, V; // Color.RGBToHSV(col, out H, out S, out V); // Color actColor = Color.HSVToRGB(H, saturation, V); // _G.SC[3] = ColorUtility.ToHtmlStringRGB(actColor); // SetOntarget(); // } public void size() { float V = this.GetComponent().value; V = 0.9f-V; _G.SC[1] = V.ToString(); SetOntarget(); } public void rotate() { float V = this.GetComponent().value; V = V * 15; _G.SC[6] = V.ToString(); SetOntarget(); } public void finish() { float V = this.GetComponent().value; _G.SC[7] = V.ToString(); if (_G.TARGETTEXTURE == "FLOOR") { } SetOntarget(); } public void Normal() { float V = this.GetComponent().value; _G.SC[5] = V.ToString(); if (_G.TARGETTEXTURE == "FLOOR") { } SetOntarget(); } public void Contrast() { float V = this.GetComponent().value; _G.SC[2] = V.ToString(); SetOntarget(); } public void GroutIntensity() { float V = this.GetComponent().value; _G.SC[9] = V.ToString(); SetOntarget(); } public static void SetOntarget() { // TODO : manage conditional updates here? if (ignoreTextureChange) { return; } //print("_G.SC[0]===="+_G.SC[0]); string code = Set.CodeTexture(); print("code form SetOntarget=== "+code); //TEXTURESPNL.UpdateTexture(code); //if (_G.PNL == "TexturesWallPNL") { TextureCall.TextureWall(code); } //if (_G.PNL == "TexturesSplashPNL") { TextureCall.TextureSplash(code); } //if (_G.PNL == "TexturesBlocPNL") { TextureCall.TextureBloc(code); } //if (_G.TARGETTEXTURE == "FLOOR") { TextureCall.TextureFloor(code); } //if (_G.PNL == "TexturesCounterPNL") { TextureCall.TextureCounter(code); } /*if (Get.o2("TEXTUREPNL/LARGE", "MODEL") != null) { if (Get.ToggleOnInChild("TEXTUREPNL/LARGE/MODEL/Viewport/ContentTextures") == _G.SC[0]) { print("from setOnTarget==="+_G.SC[0]); //name,size,contrast,c1,c2, Material Mat = Get.o1("Canvas/Panel_SCENE/PNL/TEXTUREPNL/LARGE/MODEL/Viewport/ContentTextures/" + _G.SC[0] + "/Background").GetComponent().material; string c1 = Mat.GetFloat("_tile").ToString(); string r = Mat.GetFloat("_rotation").ToString(); _G.SC[1]=c1; string codeM = Set.CodeTexture(); CREATE.ResetMaterialFromCode(Mat, codeM, _G.SC[0].Split(".")[0]); } }*/ } //DIY slider public void Color_Change(){ print(sliderSelect.value); Color pickColor = _bacgroundColor.GetComponent().sprite.texture.GetPixel(Mathf.RoundToInt(sliderSelect.value), 0); Get.o2("SHOWSELECTION/IMAGE","Image").GetComponent().material.SetColor(name,pickColor); this.gameObject.transform.Find("HEX").GetComponent().text=ColorUtility.ToHtmlStringRGB(pickColor); } public void Contrast_Change(){ if(_G.PON=="CABDOORpnl"){ Material mat = Get.o2(_G.PON+"/SHOWSELECTION/DOOR","Imagedoor").GetComponent().GetMaterial(); mat.SetFloat("_Contrast",sliderSelect.value); Get.o2("CABDOORpnl/SHOWSELECTION/DOOR", "Imagedoor").GetComponent().SetMaterial(mat, null); } // else{ // Get.o2(_G.PON+"/SHOWSELECTION/IMAGE","Image").GetComponent().material.SetFloat("_contrast",sliderSelect.value); // } if(_G.PON=="CREATORpnl"){ Material M= Get.o2("3D Object Show/Texture","Center").GetComponent().material; string Name=transform.parent.transform.parent.name; M.SetFloat("_contrast",sliderSelect.value); StaticCoroutine.Start( LibraryCreator.RTImageCaroutine( Get.o2("CREATORpnl/SHOWSELECTION/IMAGE","RawImage") )); //Get.o2("CREATORpnl/SHOWSELECTION/IMAGE","RawImage").GetComponent().texture=LibraryCreator.RTImage(); } } public static void ColorShow(){ GameObject c1=Get.o2("UNIVERSALpnl/COLOR_SLIDERS","_c1"); GameObject c2=Get.o2("UNIVERSALpnl/COLOR_SLIDERS","_c2"); GameObject contrast=Get.o2("UNIVERSALpnl/COLOR_SLIDERS","_contrast"); int c1value=Mathf.RoundToInt(c1.GetComponent().value); int c2value=Mathf.RoundToInt(c2.GetComponent().value); float contrastvalue=contrast.GetComponent().value; Color C1 = c1.transform.Find("Background").GetComponent().sprite.texture.GetPixel(c1value, 0); Color C2 = c2.transform.Find("Background").GetComponent().sprite.texture.GetPixel(c2value, 0); Material Mat=Get.o2("SHOWSELECTION/IMAGE","Image").GetComponent().material; Mat.SetColor("_c1",C1); Mat.SetColor("_c2",C2); Mat.SetFloat("_contrast",contrastvalue); } //New Color Change---------------------------------------------------------------------------------------------- public void ChangeColor() { int value = Mathf.RoundToInt(_sliderColor.value); Color actColor = _bacgroundColor.GetComponent().sprite.texture.GetPixel(value, 0); float intensity = _sliderIntensity.value / _sliderIntensity.maxValue; _ShowColor.color = Color.Lerp(Color.white, actColor, intensity); } public void ChangeIntensity() { int value = Mathf.RoundToInt(_sliderColor.value); Color actColor = _bacgroundColor.GetComponent().sprite.texture.GetPixel(value, 0); float intensity = _sliderIntensity.value / _sliderIntensity.maxValue; _ShowColor.color = Color.Lerp(Color.white, actColor, intensity); } public void AddPreset(int value) { _sliderColor.value = 0; _sliderColor.value = value; switch (value) { case 128:_sliderIntensity.value = 128f; break;//white case 153:_sliderIntensity.value = 150f; break;//gold case 4:_sliderIntensity.value = 75f; break;//grey case 5:_sliderIntensity.value = 252f; break;//black case 163:_sliderIntensity.value = 210f; break;//Coper } } }