public void SetMeshVerticesPosition(RectTransform rtParent, bool elevate, float zAxis) { float elvation = elevate ? this.Height : 0; transform.SetParent(rtParent); transform.localPosition = new Vector3(this.Location.x, this.Location.y, zAxis); MeshCreator meshCreator = new MeshCreator(); MeshRenderer meshRenderer = (MeshRenderer)gameObject.AddComponent(typeof(MeshRenderer)); MeshFilter meshFilter = (MeshFilter)gameObject.AddComponent(typeof(MeshFilter)); meshFilter.mesh.Clear(); meshFilter.mesh = meshCreator.CreateMesh2(elvation, this.AgentCoordinate.GetVector2Coordinates(), this.InitialLocation); meshFilter.mesh.name = "CustomMesh"; Material mat = new Material(Shader.Find("Specular")) { color = this.Color.GetRgb() }; meshRenderer.material = mat; //meshCollider.sharedMesh = meshFilter.mesh; transform.localRotation = Quaternion.Euler(0, 0, 180); gameObject.AddComponent <MeshCollider>(); }