Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TileSpawner : MonoBehaviour
- {
- private List<int> testBlueprint;
- public string currentTileset = "dirt";
- private float startX = -8.5f;
- private float startY = 0;
- private float tileSize = 1f;
- public GameObject tilePrefab;
- private void Awake()
- {
- testBlueprint = new List<int> { 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14 };
- }
- // Start is called before the first frame update
- void Start()
- {
- generateRow("dirt", testBlueprint);
- }
- public void generateRow(string currentTileset, List<int> blueprint)
- {
- for (int i = 0; i < blueprint.Count; i++) {
- GameObject t = Instantiate(tilePrefab, new Vector2(startX + (tileSize *i), startY), Quaternion.identity);
- t.GetComponent<TileController>().initTile(currentTileset, blueprint[i]);
- }
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement