Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TileController : MonoBehaviour
- {
- public SpriteRenderer spriteRenderer;
- public Sprite[] dirtTiles;
- public Sprite[] fossilTiles;
- public Sprite[] rockTiles;
- // store your sprites in these
- private string tileSet;
- private int tileNumber;
- public void initTile(string tSet, int tNum){
- this.tileSet = tSet;
- this.tileNumber = tNum;
- this.spriteRenderer.sprite = getTileAppearance();
- }
- private Sprite getTileAppearance()
- {
- switch (tileSet)
- {
- case "dirt":
- return dirtTiles[tileNumber];
- case "fossil":
- return fossilTiles[tileNumber];
- case "rock":
- return rockTiles[tileNumber];
- default:
- return dirtTiles[tileNumber];
- }
- }
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
Add Comment
Please, Sign In to add comment