Created
August 12, 2020 09:08
-
-
Save Plnda/3455a450f512f64cd2c48f41717c7ee2 to your computer and use it in GitHub Desktop.
Tilecheck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetGroundTypeFromPosition(Vector3 position) | |
{ | |
if(sortedLayers == null) | |
{ | |
sortedLayers = layers | |
.ToArray() | |
.OrderByDescending(x => x.GetComponent<TilemapRenderer>().sortingOrder); | |
} | |
foreach(var tileMap in sortedLayers) | |
{ | |
var tile = tileMap.GetTile(Vector3Int.RoundToInt(position)); | |
if(tile != null) | |
{ | |
return tileMap.name; | |
} | |
} | |
return "Ground"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment