GameObject createSea() {// parent = new GameObject("Sea"); // parent.transform.parent = gameObject.transform; //1) Create an empty GameObject with the required Components // GameObject seaGo = PrimitiveHelper.CreatePrimitive(PrimitiveType.Cylinder, false, "Sea"); GameObject seaGo = new GameObject("Sea"); DrawCylinder cylinder = seaGo.AddComponent <DrawCylinder>(); cylinder.segmentsHeight = 10; cylinder.segmentsRadial = 40; // Mesh meshCube = PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cube); seaGo.transform.position = Vector3.down * Aviator.seaRadius; seaGo.transform.Rotate(Vector3.right * -90); // seaGo.transform.localScale = new Vector3(1200, 400, 1200); // for unity built-in PrimitiveType.Cylinder // remember to divide y by cylinder.segmentsHeight seaGo.transform.localScale = new Vector3(Aviator.seaRadius, Aviator.seaLength / cylinder.segmentsHeight, Aviator.seaRadius); // for self-built DrawCylinder seaGo.transform.parent = gameObject.transform; //9) Give it a Material MeshRenderer seaMr = seaGo.AddComponent <MeshRenderer>(); Material seaMa = seaMr.material; seaMa.SetColor("_Color", AviatorColors.Blue); PrimitiveHelper.SetMaterialTransparent(seaMa); seaGo.AddComponent <Sea>(); return(seaGo); }
// Start is called before the first frame update void Start() { mesh = gameObject.GetComponent <MeshFilter>().mesh; vertices = mesh.vertices; DrawCylinder cylinder = gameObject.GetComponent <DrawCylinder>(); if (cylinder.isDiscrete) { points = cylinder.groupSamePoint(); for (int i = 0; i < points.Length; i++) { waves.Add(new Wave(vertices[points[i][0]])); } } else { for (int i = 0; i < vertices.Length; i++) { waves.Add(new Wave(vertices[i])); } } }