using UnityEngine; public class RedrawCab : MonoBehaviour { public static void reWood() { for (var i = 0; i < _G.OBJnum + 1; i++) { if (_G.OBJs[i] != null) if (_G.OBJs[i][2] == "Cabinet") { GameObject Cab = GameObject.Find(_G.OBJs[i][0]).gameObject; if (Cab.transform.Find("S1")) scaleTexture(i, "S1"); if (Cab.transform.Find("S2")) scaleTexture(i, "S2"); if (Cab.transform.Find("S3")) scaleTexture(i, "S3"); if (Cab.transform.Find("S4")) scaleTexture(i, "S4"); if (Cab.transform.Find("K1")) scaleTexture(i, "K1"); if (Cab.transform.Find("K2")) scaleTexture(i, "K2"); if (Cab.transform.Find("K3")) scaleTexture(i, "K3"); if (Cab.transform.Find("K4")) scaleTexture(i, "K4"); if (Cab.transform.Find("K5")) scaleTexture(i, "K5"); if (Cab.transform.Find("K6")) scaleTexture(i, "K6"); if (Cab.transform.Find("TOP")) scaleTexture(i, "TOP"); if (Cab.transform.Find("UNDER")) scaleTexture(i, "UNDER"); if (Cab.transform.Find("TOPC")) scaleTextureAll(i, "TOPC"); if (Cab.transform.Find("UNDERC")) scaleTextureAll(i, "UNDERC"); if (Cab.transform.Find("T1")) scaleTexture(i, "T1"); if (Cab.transform.Find("T2")) scaleTexture(i, "T2"); if (_G.OBJs[i][4] == "Corner wall") { for (int j = 0; j < GameObject.Find("TOPG").transform.childCount; j++) { scaleTextureG(i, GameObject.Find("TOPG").transform.GetChild(j).gameObject ); } for (int j = 0; j < GameObject.Find("UNDERG").transform.childCount; j++) { scaleTextureG(i, GameObject.Find("UNDERG").transform.GetChild(j).gameObject); } } //_G.OBJs[i][10] = _G.Woods; } } } public static void reCounterthis(string CODE) { string[] TC=CODE.Split(","[0]); GameObject obj=GameObject.Find(SceneModeManager.SelectedName).gameObject; obj.GetComponent().material.mainTexture = DOIT.GetTex(TC[0]); obj.GetComponent().material.color = DOIT.CSc(TC[2], 255); obj.GetComponent().material.SetFloat("_Glossiness", DOIT.GetShine(TC[4])); } /*public static void reKnob(string K) { print("--------------ReKnob-------------------"); GameObject[] knobs; knobs = GameObject.FindGameObjectsWithTag("knob"); foreach (GameObject obj in knobs) { GameObject kn= Addknob.KnobCHANGE(K); kn.transform.position = obj.transform.position; kn.transform.rotation = obj.transform.rotation; foreach (Transform child in obj.transform) { Destroy(child.gameObject); } for(int i= kn.transform.childCount; i> 0; i--) { kn.transform.GetChild(i - 1).SetParent(obj.transform); } Destroy(kn); } DOIT.REDOALLCab_G(); }*/ //------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------FUNCTION------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------- static void scaleTexture(int i,string Os) { GameObject C = GameObject.Find(_G.OBJs[i][0]).gameObject; GameObject O = C.transform.Find(Os).gameObject; O.GetComponent().material = new Material(Shader.Find("Universal Render Pipeline/Lit")); //O.GetComponent().material.mainTexture = _G.TEXCABBOX; float sx = O.gameObject.transform.localScale.x * C.gameObject.transform.localScale.x; float sy = O.transform.localScale.y * C.transform.localScale.y; O.GetComponent().material.mainTextureScale = new Vector2(sx / 24f, sy / 24f); } static void scaleTextureG(int i, GameObject O) { O.GetComponent().material = new Material(Shader.Find("Universal Render Pipeline/Lit")); //O.GetComponent().material.mainTexture = _G.TEXCABBOX; } static void scaleTextureAll(int i, string Os) { GameObject C = GameObject.Find(_G.OBJs[i][0]).gameObject; GameObject O = C.transform.Find(Os).gameObject; /*for (int k = 0; k < O.transform.childCount; k++) { O.gameObject.transform.GetChild(k).gameObject.GetComponent().material.mainTexture = _G.TEXCABBOX; }*/ float sx = O.gameObject.transform.localScale.x * C.gameObject.transform.localScale.x; float sy = O.transform.localScale.y * C.transform.localScale.y; O.GetComponent().material.mainTextureScale = new Vector2(sx / 24f, sy / 24f); } }