using UnityEngine; public class ConstructDECO : MonoBehaviour { static Texture2D TEX; static float SIZE; static Color COL; static string ROT; static float SHINE; static Sprite TD; static Sprite TDB; static Sprite TDD; public static void AddObject(int nO) { string[] C = _G.OBJs[nO]; float w = DOIT.ConvertStringToNumber(C[6]); float h = DOIT.ConvertStringToNumber(C[7]); float d = DOIT.ConvertStringToNumber(C[8]); float px = DOIT.ConvertStringToNumber(C[15]); float py = DOIT.ConvertStringToNumber(C[16]); float pz = DOIT.ConvertStringToNumber(C[17]); float rx = DOIT.ConvertStringToNumber(C[18]); float ry = DOIT.ConvertStringToNumber(C[19]); float rz = DOIT.ConvertStringToNumber(C[20]); SetTex(C[61]); //create BASE GameObject BASE = GameObject.CreatePrimitive(PrimitiveType.Cube);//new GameObject(); BASE.transform.localScale = new Vector3(w + 0.5f, h + 0.5f, d + 0.5f); BASE.name = _G.OBJs[nO][0]; BASE.transform.parent = GameObject.Find("SCENE").transform; BASE.tag = "deco"; int index = System.Array.IndexOf(_L.Cab, C[1]); float sw = DOIT.ConvertStringToNumber(_L.Cab[index + 3]); float sh = DOIT.ConvertStringToNumber(_L.Cab[index + 4]); float sd = DOIT.ConvertStringToNumber(_L.Cab[index + 5]); _G.SC[0] = _L.Cab[index - 1]; if (C[1] != "DOOR PNL") { GameObject DECO = Instantiate(Resources.Load("Objects/DECO/" + _G.SC[0], typeof(GameObject))) as GameObject; DECO.transform.localScale = new Vector3(w / sw, h / sh, d / sd); DECO.name = _G.OBJs[nO][1]; DECO.transform.SetParent(BASE.transform); DECO.transform.localRotation = Quaternion.Euler(0, 180, 0); for (int i = 0; i < DECO.transform.childCount; i++) { DECO.transform.GetChild(i).GetComponent().material = Resources.Load("MATERIALS/ST") as Material; DECO.transform.GetChild(i).GetComponent().material.mainTexture = TEX; DECO.transform.GetChild(i).GetComponent().material.color = COL; DECO.transform.GetChild(i).GetComponent().material.SetFloat("_Metallic", 0.0f); DECO.transform.GetChild(i).GetComponent().material.SetFloat("_Glossiness", SHINE); DECO.transform.GetChild(i).GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; DOIT.SetSizeTex(DECO.transform.GetChild(i).gameObject, 24, 24, 0, 0, 0, 0, 90, 90); } } if (C[1] == "DOOR PNL") { SetSPRITE(C[61]); GameObject db = GameObject.CreatePrimitive(PrimitiveType.Cube); db.GetComponent().enabled = false; db.transform.localScale = new Vector3(w, h, d); db.name = "db"; db.GetComponent().material = Resources.Load("MATERIALS/ST") as Material; db.GetComponent().material.mainTexture = TEX; db.GetComponent().material.color = COL; db.GetComponent().material.SetFloat("_Metallic", 0.0F); db.gameObject.GetComponent().material.EnableKeyword("_GLOSSYREFLECTIONS_OFF"); DOIT.SetSizeTex(db.gameObject, 24, 24, 0, 0, 0, 0, 90, 90); GameObject sr = new GameObject(); sr.name = "sr"; //sr.tag = "cabdoor"; sr.AddComponent(); sr.gameObject.GetComponent().sprite = TD; if (sh <= 8) sr.gameObject.GetComponent().sprite = TDB; //if (p == "d") sr.gameObject.GetComponent().sprite = TDD; sr.gameObject.GetComponent().drawMode = SpriteDrawMode.Sliced; sr.gameObject.GetComponent().size = new Vector2(sw / 8f, sh / 8f); sr.gameObject.transform.position = new Vector3(0, 0, -sd / 2 - 0.1f); sr.gameObject.GetComponent().material = Resources.Load("MATERIALS/ST") as Material; sr.GetComponent().material.color = COL; sr.GetComponent().material.SetFloat("_Metallic", 0.0f); sr.GetComponent().material.SetFloat("_Glossiness", SHINE); sr.GetComponent().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; sr.GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; sr.GetComponent().receiveShadows = true; sr.gameObject.transform.SetParent(db.transform); sr.gameObject.transform.localScale = new Vector3(8f / sw, 8f / sh, 1); db.transform.SetParent(BASE.transform); } print("C[73]===" + C[73]); if (C[73] == "none") { C[73] = "0,0,0,0,0,0"; } string[] AOP = C[73].Split(","[0]); float AOP1 = DOIT.ConvertStringToNumber(AOP[0]); float AOP2 = DOIT.ConvertStringToNumber(AOP[1]); float AOP3 = DOIT.ConvertStringToNumber(AOP[2]); float AOP4 = DOIT.ConvertStringToNumber(AOP[3]); CreatePoint(BASE, "PO1", -w / 2 - AOP1, h / 2, d / 2 - 12); CreatePoint(BASE, "PO2", -w / 2 - AOP2, h / 2, d / 2); CreatePoint(BASE, "PO3", w / 2 + AOP3, h / 2, d / 2); CreatePoint(BASE, "PO4", w / 2 + AOP4, h / 2, d / 2 - 12); //print("(C[1]===" + C[1]); if (C[1] == "REH3624") { if (C[62] == "none") C[62] = UIT.Global(Header.Int,_G.G);//GGlobalSelectionManager.GetValue(GlobalOption.INTPNL_1);//BOX color code if (C[64] == "none") C[64] = UIT.Global(Header.Ogee,_G.G);//GGlobalSelectionManager.GetValue(GlobalOption.OGEE_5); if (C[70] == "none") C[70] = "m1,0,m3,m4,0,0"; if (C[66] == "none") C[66] = "HEAD000,0,FFFFFF,r0,S"; //SPLASH if (C[54] == "none") C[54] = UIT.Global(Header.Splash,_G.G);//GGlobalSelectionManager.GetValue(GlobalOption.SPLA_9);//Texture if (C[55] == "none") C[55] = "0,0,0,0";//left,hight,right,back,Tex,sizeX,sizeY,Rot,Shine if (C[56] == "none") C[56] = "0,0,0,0";//left,hight,right,back,Tex,sizeX,sizeY,Rot,Shine C[50] = "NONE";//Filler Left C[51] = "NONE";//Filler Right BASE.tag = "cabwall"; DOBS.SplashC(BASE, C[55], w, h, d, C[54]); //ADD LIGHT GameObject lightGameObject = new GameObject("SpotLight"); Light lightComp = lightGameObject.AddComponent(); lightGameObject.transform.localPosition = new Vector3(0, -h / 2 + 20, 0); lightGameObject.transform.localRotation = Quaternion.Euler(90, 0, 0); lightGameObject.GetComponent().type = LightType.Spot; lightGameObject.GetComponent().intensity = 12; lightGameObject.GetComponent().range = 100; lightGameObject.GetComponent().spotAngle = 80; lightGameObject.GetComponent().renderMode = LightRenderMode.ForcePixel; lightGameObject.GetComponent().enabled = false; if (_G.OBJs[nO][40] == "On") lightGameObject.GetComponent().enabled = true; lightGameObject.transform.SetParent(BASE.transform); } Mesure.Addpoints("BASE",BASE); //Stet in scene BASE.transform.position = new Vector3(px, py, pz); BASE.transform.localRotation = Quaternion.Euler(rx, ry, rz); BASE.AddComponent(typeof(MoveObject)); BASE.GetComponent().material = Resources.Load("MATERIALS/INVISIBLE") as Material; BASE.transform.SetParent(GameObject.Find("SCENE").transform); BASE.transform.localScale = new Vector3(w + 0.5f, h + 0.5f, d + 0.5f); } static void SetTex(string tc) { string[] TC = tc.Split(","[0]); print("TC[0]===" + TC[0]); print("TC[0]===" + TC[0]); TEX = DOIT.GetTex(TC[0].Replace("DCAB", "TEXT")); SIZE = DOIT.ConvertStringToNumber(TC[1]); COL = DOIT.CSc(TC[2], 100); ROT = TC[3]; if (ROT == "r9") TEX = DOIT.Rotate(TEX); SHINE = DOIT.GetShine(TC[4]); } static void SetSPRITE(string tc) { string[] TC = tc.Split(","[0]); TD = DOIT.GetSprite(TC[0]); TDB = DOIT.GetSprite(TC[0] + "B"); TDD = DOIT.GetSprite(TC[0] + "D"); } public static void CreatePoint(GameObject Base, string Name, float x, float y, float z) { GameObject point = GameObject.CreatePrimitive(PrimitiveType.Cube); point.GetComponent().enabled = false; point.name = Name; point.transform.position = new Vector3(x, y, z); point.transform.localScale = new Vector3(6, 6, 6); point.transform.parent = Base.transform; point.tag = "point"; point.transform.GetComponent().material = Resources.Load("MATERIALS/INVISIBLE") as Material; } }