using UnityEngine; public class ConstructCounter : MonoBehaviour { static Texture2D Tex; static float Size; static Color Col; static float Shine; public static void AddCounter(int nO) { string[] C = _G.OBJs[nO]; string Name = _G.OBJs[nO][0]; float w = DOIT.ConvertStringToNumber(C[6]); float h = DOIT.ConvertStringToNumber(C[7]); float d = DOIT.ConvertStringToNumber(C[8]); float t = DOIT.ConvertStringToNumber(C[9]); 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]); //SetTexture(C[41]); //setTexture(_G.CTC); //create Counter GameObject Counter = GameObject.CreatePrimitive(PrimitiveType.Cube); Counter.transform.localScale = new Vector3(w + 0.5f, h + 0.5f, d + 0.5f); Counter.name = Name; Counter.transform.parent = GameObject.Find("SCENE").transform; if (_G.OBJs[nO][1] == "TOPC102") { GameObject Tt = CreateMcx("Tt", w, d, 0, h / 2, 0, 90, 0, 0); Tt.transform.parent = Counter.transform; GameObject Tf = CreateMcx("Tf", w, t, 0, h / 2 - t / 2, -d / 2, 0, 0, 0); Tf.transform.parent = Counter.transform; GameObject Tb = CreateMcx("Tb", w, t, 0, h / 2 - t / 2, d / 2, 0, 180, 0); Tb.transform.parent = Counter.transform; GameObject Ll = CreateMcx("Ll", h, d, -w / 2, 0, 0, 0, 90, 90); Ll.transform.parent = Counter.transform; GameObject Lf = CreateMcx("Lf", t, h - t, -w / 2 + t / 2, -t / 2, -d / 2, 0, 0, 0); Lf.transform.parent = Counter.transform; GameObject Lb = CreateMcx("Lb", t, h - t, -w / 2 + t / 2, -t / 2, d / 2, 0, 180, 0); Lb.transform.parent = Counter.transform; GameObject Lr = CreateMcx("Lr", h - t, d, -w / 2 + t, -t / 2, 0, 0, -90, 90); Lr.transform.parent = Counter.transform; GameObject Rr = CreateMcx("Rr", h, d, w / 2, 0, 0, 0, -90, 90); Rr.transform.parent = Counter.transform; GameObject Rf = CreateMcx("Rf", t, h - t, w / 2 - t / 2, -t / 2, -d / 2, 0, 0, 0); Rf.transform.parent = Counter.transform; GameObject Rb = CreateMcx("Rb", t, h - t, w / 2 - t / 2, -t / 2, d / 2, 0, 180, 0); Rb.transform.parent = Counter.transform; GameObject Rl = CreateMcx("Rl", h - t, d, w / 2 - t, -t / 2, 0, 0, 90, 90); Rl.transform.parent = Counter.transform; } if (_G.OBJs[nO][1] == "TOPC101") { GameObject Tt = CreateMcx("Tt", w, d, 0, h / 2, 0, 90, 0, 0); Tt.transform.parent = Counter.transform; GameObject Tf = CreateMcx("Tf", w, t, 0, h / 2 - t / 2, -d / 2, 0, 0, 0); Tf.transform.parent = Counter.transform; GameObject Tb = CreateMcx("Tb", w, t, 0, h / 2 - t / 2, d / 2, 0, 180, 0); Tb.transform.parent = Counter.transform; GameObject Ll = CreateMcx("Ll", h, d, -w / 2, 0, 0, 0, 90, 90); Ll.transform.parent = Counter.transform; GameObject Lf = CreateMcx("Lf", t, h - t, -w / 2 + t / 2, -t / 2, -d / 2, 0, 0, 0); Lf.transform.parent = Counter.transform; GameObject Lb = CreateMcx("Lb", t, h - t, -w / 2 + t / 2, -t / 2, d / 2, 0, 180, 0); Lb.transform.parent = Counter.transform; GameObject Lr = CreateMcx("Lr", h - t, d, -w / 2 + t, -t / 2, 0, 0, -90, 90); Lr.transform.parent = Counter.transform; GameObject Rr = CreateMcx("Rr", t, d, w / 2, h / 2 - t / 2, 0, 0, -90, 90); Rr.transform.parent = Counter.transform; } if (_G.OBJs[nO][1] == "TOPC104") { GameObject Tt = CreateMcx("Tt", w, d, 0, h / 2, 0, 90, 0, 0); Tt.transform.parent = Counter.transform; GameObject Tf = CreateMcx("Tf", w, t, 0, h / 2 - t / 2, -d / 2, 0, 0, 0); Tf.transform.parent = Counter.transform; GameObject Tb = CreateMcx("Tb", w, t, 0, h / 2 - t / 2, d / 2, 0, 180, 0); Tb.transform.parent = Counter.transform; GameObject Ll = CreateMcx("Ll", t, d, -w / 2, h / 2 - t / 2, 0, 0, 90, 90); Ll.transform.parent = Counter.transform; GameObject Rr = CreateMcx("Rr", t, d, w / 2, h / 2 - t / 2, 0, 0, -90, 90); Rr.transform.parent = Counter.transform; } if (_G.OBJs[nO][1] == "TOPC103") { GameObject Tt = CreateMcx("Tt", w, d, 0, h / 2, 0, 90, 0, 0); Tt.transform.parent = Counter.transform; GameObject Tf = CreateMcx("Tf", w, t, 0, h / 2 - t / 2, -d / 2, 0, 0, 0); Tf.transform.parent = Counter.transform; GameObject Tb = CreateMcx("Tb", w, t, 0, h / 2 - t / 2, d / 2, 0, 180, 0); Tb.transform.parent = Counter.transform; GameObject Ll = CreateMcx("Ll", t, d, -w / 2, h / 2 - t / 2, 0, 0, 90, 90); Ll.transform.parent = Counter.transform; GameObject Rr = CreateMcx("Rr", h, d, w / 2, 0, 0, 0, -90, 90); Rr.transform.parent = Counter.transform; GameObject Rf = CreateMcx("Rf", t, h - t, w / 2 - t / 2, -t / 2, -d / 2, 0, 0, 0); Rf.transform.parent = Counter.transform; GameObject Rb = CreateMcx("Rb", t, h - t, w / 2 - t / 2, -t / 2, d / 2, 0, 180, 0); Rb.transform.parent = Counter.transform; GameObject Rl = CreateMcx("Rl", h - t, d, w / 2 - t, -t / 2, 0, 0, 90, 90); Rl.transform.parent = Counter.transform; } if (_G.OBJs[nO][1] == "TOPC105") { GameObject Tt = CreateMcx("Tt", w, d, 0, h / 2, 0, 90, 0, 0); Tt.transform.parent = Counter.transform; GameObject Tf = CreateMcx("Tf", w, h, 0, 0, -d / 2, 0, 0, 0); Tf.transform.parent = Counter.transform; GameObject Tb = CreateMcx("Tb", w, h, 0, 0, d / 2, 0, 180, 0); Tb.transform.parent = Counter.transform; GameObject Ll = CreateMcx("Ll", h, d, -w / 2, 0, 0, 0, 90, 90); Ll.transform.parent = Counter.transform; GameObject Rr = CreateMcx("Rr", h, d, w / 2, 0, 0, 0, -90, 90); Rr.transform.parent = Counter.transform; } //Stet in scene Counter.transform.position = new Vector3(px, py, pz); Counter.transform.localRotation = Quaternion.Euler(rx, ry, rz); Counter.AddComponent(typeof(MoveObject)); Counter.GetComponent().material = Resources.Load("MATERIALS/INVISIBLE") as Material; //BM.INV; Counter.transform.SetParent(GameObject.Find("SCENE").transform); } public static GameObject CreateMcx(string n, float sx, float sy, float px, float py, float pz, float rx, float ry, float rz) { GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Quad); obj.transform.localScale = new Vector3(sx, sy, 1); obj.transform.position = new Vector3(px, py, pz); obj.transform.localRotation = Quaternion.Euler(rx, ry, rz); obj.GetComponent().material = Resources.Load("MATERIALS/ST") as Material; obj.GetComponent().material.mainTexture = Tex; obj.GetComponent().material.color = Col; obj.GetComponent().material.SetFloat("_Glossiness", Shine); obj.GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; obj.name = n; obj.GetComponent().enabled = false; //print("size===" + Size); DOIT.SetSizeTex(obj, Size * 12, Size * 12, 0, 0, 0, 0, 90, 90); obj.tag = "counter"; return obj; } //public static void SetTexture(string ctex) //{ // /*if(ctex.Split('?').Length==1)ctex=ctex+"?0"; // string[] texcode=ctex.Split('?'); // //print("texcode[0]==="+texcode[0]); // Tex = Get.Texture2DFromTextureName( texcode[0], texcode[1] ); // Col =DOIT.CSc(Get.TextureValue(texcode[0],11), 255); // TAG = "Untagged"; // string[] CT = ctex.Split(","[0]); // Tex = DOIT.GetTex(CT[0]); // Col = DOIT.CSc(CT[2], 255); // Size = DOIT.ConvertStringToNumber(CT[1]); // if (CT[3] == "r9" || CT[3] == "r90") Tex = DOIT.Rotate(Tex); // Shine = DOIT.GetShine(CT[4]);*/ // print("ctex===" + ctex); // if (ctex == "none") { ctex = "WOOD101,2,FFFFFF,r0,M"; } // if (ctex.IndexOf("CT.") == -1) // { // string[] CT = ctex.Split(','); // Tex = DOIT.GetTex(CT[0]); // Col = DOIT.CSc(CT[2], 255); // Size = DOIT.ConvertStringToNumber(CT[1]); // if (CT[3] == "r9" || CT[3] == "r90") Tex = DOIT.Rotate(Tex); // Shine = DOIT.GetShine(CT[4]); // } // if (ctex.IndexOf("CT.") != -1) // { // string[] CT = ctex.Split(','); // string cols = Get.CounterValue(CT[0], 11); // string texs = Get.CounterValue(CT[0], 9); // Col = DOIT.CSc(cols, 255); // Tex = DOIT.GetTex(texs); // Size = DOIT.ConvertStringToNumber("2"); // //if (CT[3] == "r9" || CT[3] == "r90") Tex = DOIT.Rotate(Tex); // Shine = DOIT.GetShine("S"); // } //} public static void SetTexture(string ctex) { /*if(ctex.Split('?').Length==1)ctex=ctex+"?0"; string[] texcode=ctex.Split('?'); //print("texcode[0]==="+texcode[0]); Tex = Get.Texture2DFromTextureName( texcode[0], texcode[1] ); Col =DOIT.CSc(Get.TextureValue(texcode[0],11), 255); TAG = "Untagged"; string[] CT = ctex.Split(","[0]); Tex = DOIT.GetTex(CT[0]); Col = DOIT.CSc(CT[2], 255); Size = DOIT.ConvertStringToNumber(CT[1]); if (CT[3] == "r9" || CT[3] == "r90") Tex = DOIT.Rotate(Tex); Shine = DOIT.GetShine(CT[4]);*/ print("ctex===" + ctex); if (ctex == "none") { ctex = "WOOD101,2,FFFFFF,r0,M"; } if (ctex.IndexOf("CT.") == -1) { string[] CT = ctex.Split(','); Tex = DOIT.GetTex(CT[0]); Col = DOIT.CSc(CT[2], 255); Size = DOIT.ConvertStringToNumber(CT[1]); if (CT[3] == "r9" || CT[3] == "r90") Tex = DOIT.Rotate(Tex); Shine = DOIT.GetShine(CT[4]); } if (ctex.IndexOf("CT.") != -1) { string[] CT = ctex.Split(','); //string cols = Get.CounterValue(CT[0], 11); //string texs = Get.CounterValue(CT[0], 9); string cols = Get.LibraryValue(CT[0], CsvHeaders.Texture,"Counter"); //string texs = Get.CounterValue(CT[0], CsvHeaders.Filter_4); Col = DOIT.CSc(cols, 255); //Tex = DOIT.GetTex(texs); Size = DOIT.ConvertStringToNumber("2"); //if (CT[3] == "r9" || CT[3] == "r90") Tex = DOIT.Rotate(Tex); Shine = DOIT.GetShine("S"); } } }