Advertisement
ttkhila

Teste Coordenadas Unity - Floor

Jun 17th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Tilemaps;
  5.  
  6. public class Floor : MonoBehaviour
  7. {
  8.     //Classe que irá ser inserida em Tiles 'Andáveis'
  9.  
  10.     [HideInInspector]
  11.     public TilemapRenderer tilemapRenderer;
  12.     public int order { get { return tilemapRenderer.sortingOrder; } }
  13.  
  14.     public int contentOrder;
  15.     public Vector3Int minXY;
  16.     public Vector3Int maxXY;
  17.  
  18.     [HideInInspector]
  19.     public Tilemap tilemap;
  20.  
  21.     void Awake()
  22.     {
  23.         tilemapRenderer = GetComponent<TilemapRenderer>();
  24.         tilemap = GetComponent<Tilemap>();
  25.     }
  26.  
  27.     public List<Vector3Int> loadTiles() {
  28.         List<Vector3Int> tiles = new List<Vector3Int>();
  29.         for (int i=minXY.x; i<=maxXY.x; i++) {
  30.             for (int j=minXY.y; j<=maxXY.y; j++) {
  31.                 Vector3Int currentPos = new Vector3Int(i, j, 0);
  32.                 if (tilemap.HasTile(currentPos)) {
  33.                     tiles.Add(currentPos);
  34.                 }
  35.             }
  36.         }
  37.         return tiles;
  38.     }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement