Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MultiMesh : MonoBehaviour {
  5.     public int numberOfSections;
  6.     public SectionMap midSection;
  7.     public SectionMap endSection;
  8.     private CombineInstance[] combine;
  9.     private MeshFilter meshFilter;
  10.     // Use this for initialization
  11.     void Start () {
  12.         int tileSize = GameObject.FindGameObjectWithTag("tile manager").GetComponent<TileMap>().tileSize;
  13.         meshFilter = gameObject.GetComponent<MeshFilter>();
  14.         meshFilter.mesh = new Mesh();
  15.         combine = new CombineInstance[midSection.tiles.Count];
  16.         for (int i = 0; i < midSection.tiles.Count; i++){
  17.             combine[i].mesh = midSection.tiles[i].tile;
  18.             Vector3 newPos = new Vector3(i * tileSize, 0, 0);
  19.             Vector3 scale = new Vector3(1, 1, 1);
  20.             combine[i].transform = Matrix4x4.TRS (newPos, Quaternion.identity, scale);
  21.         }
  22.         meshFilter.mesh.CombineMeshes(combine, false, true);
  23.  
  24.     }
  25.    
  26.     // Update is called once per frame
  27.     void Update () {
  28.    
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement