using UnityEngine; public class Shape6 : MonoBehaviour { public static GameObject B2(float w,float d,float dd,float t,float px1, float py1, float px2, float py2, float px3, float py3, float px4, float py4, float px5, float py5, float px6, float py6) { GameObject S = new GameObject(); S.name = "S"; S.AddComponent(typeof(MeshFilter)); S.AddComponent(typeof(MeshRenderer)); S.GetComponent().mesh = CreateMeshShapeL(w,d,dd, px1, py1, px2, py2, px3, py3, px4, py4, px5, py5, px6, py6); S.GetComponent().material = UIT_MATERIAL.GetMaterial(UIT.Global(Header.Counter,_G.G)); S.tag = "counter"; Side(S,dd,t, -w/2+dd/2,-d/2, -90,0, 0); Side(S, d, t, -w / 2 , 0, 0, 90, 90); Side(S, w, t, 0 , d / 2, 90, 0, 0); Side(S, dd, t, w/2, d / 2-dd/2, 0, -90, 90); Side(S, w-dd, t, w / 2-(w-dd)/2, d / 2 - dd , -90, 0, 0); Side(S, d - dd, t, -w / 2+dd, -d / 2+(d-dd)/2 , 0, -90, -90); return S; } public static Mesh CreateMeshShapeL(float w, float d, float dd, float px1, float py1, float px2, float py2, float px3, float py3, float px4, float py4, float px5, float py5, float px6, float py6) { Mesh m = new Mesh(); float a = dd / w; m.vertices = new Vector3[] { new Vector3(px1, py1), new Vector3(px2, py2), new Vector3(px3, py3), new Vector3(px4, py4), new Vector3(px5, py5), new Vector3(px6, py6) }; m.uv = new Vector2[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, a), new Vector2(a, a), new Vector2(a, 1), new Vector2(0, 1) }; m.triangles = new int[] { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 }; m.RecalculateNormals(); return m; } public static GameObject Side(GameObject S,float ws, float t, float px, float pz, float rx,float ry, float rz) { GameObject s = GameObject.CreatePrimitive(PrimitiveType.Quad); s.transform.localScale = new Vector3(ws, t, 1); s.transform.localRotation = Quaternion.Euler(rx, ry, rz); s.transform.position = new Vector3(px, pz, t / 2); S.GetComponent().material = UIT_MATERIAL.GetMaterial(UIT.Global(Header.Counter,_G.G)); Vector2 scaler = new Vector2(ws / 36, t / 36); s.GetComponent().material.mainTextureScale = scaler; s.transform.parent = S.transform; s.name = "side"; s.tag = "unhit"; return s; } }