public void GenerateMeshFromQuads() { int count = this.quads.Count; Vector3[] vertices; Vector2[] uv; int[] triangles; UnityUtils.SetupVerticesForQuads(count, out vertices, out uv, out triangles); for (int i = 0; i < count; i++) { Vector4 vector = this.quads[i]; float x = vector.x; float y = vector.y; float z = vector.z; float w = vector.w; UnityUtils.SetQuadVertices(x, z, y, w, i, vertices); } this.quads = null; this.mesh = UnityUtils.CreateMeshWithVertices(vertices, uv, triangles); this.tiles = new GameObject(this.name); UnityUtils.SetupMeshMaterial(this.tiles, this.mesh, null); }
private void CreateSpawnMesh() { Board <Entity> board = Service.Get <BoardController>().Board; if (this.meshCells == null) { this.meshCells = new List <BoardCell <Entity> >(); } IState currentState = Service.Get <GameStateMachine>().CurrentState; bool flag = currentState is HomeState || currentState is EditBaseState || currentState is ApplicationLoadState; int i = 0; int boardSize = board.BoardSize; while (i < boardSize) { for (int j = 0; j < boardSize; j++) { BoardCell <Entity> cellAt = board.GetCellAt(i, j, true); if ((cellAt.Flags & 4u) != 0u || (!flag && (cellAt.Flags & 16u) != 0u)) { this.meshCells.Add(cellAt); } } i++; } int num = 23; int num2 = 47; int quadCount = this.meshCells.Count + num2 * 4; Vector3[] vertices; Vector2[] uv; int[] triangles; UnityUtils.SetupVerticesForQuads(quadCount, out vertices, out uv, out triangles); int num3 = 0; int k = 0; int count = this.meshCells.Count; while (k < count) { BoardCell <Entity> boardCell = this.meshCells[k]; this.SetGridQuadVertices(boardCell.X, boardCell.Z, num3++, vertices); k++; } this.meshCells.Clear(); int num4 = -num - 1; int num5 = num; int l = 0; int num6 = num4; int num7 = num5; while (l < num2) { this.SetGridQuadVertices(num4, num6, num3++, vertices); this.SetGridQuadVertices(num6, num5, num3++, vertices); this.SetGridQuadVertices(num5, num7, num3++, vertices); this.SetGridQuadVertices(num7, num4, num3++, vertices); l++; num6++; num7--; } this.mesh = UnityUtils.CreateMeshWithVertices(vertices, uv, triangles); }