Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MultiMesh : MonoBehaviour {
- public int numberOfSections;
- public SectionMap midSection;
- public SectionMap endSection;
- private CombineInstance[] combine;
- private MeshFilter meshFilter;
- // Use this for initialization
- void Start () {
- int tileSize = GameObject.FindGameObjectWithTag("tile manager").GetComponent<TileMap>().tileSize;
- meshFilter = gameObject.GetComponent<MeshFilter>();
- meshFilter.mesh = new Mesh();
- combine = new CombineInstance[midSection.tiles.Count];
- for (int i = 0; i < midSection.tiles.Count; i++){
- combine[i].mesh = midSection.tiles[i].tile;
- Vector3 newPos = new Vector3(i * tileSize, 0, 0);
- Vector3 scale = new Vector3(1, 1, 1);
- combine[i].transform = Matrix4x4.TRS (newPos, Quaternion.identity, scale);
- }
- meshFilter.mesh.CombineMeshes(combine, false, true);
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement