/UnityScripts

Helpfull unity scripts

Primary LanguageC#MIT LicenseMIT

UnityScripts

Helpfull unity scripts

Get tag

if( hit.transform.gameObject.tag == "Interact"){
  Debug.Log("Colide with interact tile");
}

Get dropdown in inspector

public enum TileSetType {Forest,Grassland,Housing};

[SerializeField] public TileSetType tileType;

Spawn items in the world with X and z cordinats

private Dictionary<HexTile , GameObject> hexToGameObjectMap;

public void SpawnUnitAt(GameObject PlayerUnitPrefab, int q, int r)
{
  GameObject myHex = hexToGameObjectMap[GetHexAt(q,r)];
  //Spawn player in
  Instantiate(PlayerUnitPrefab, myHex.transform.position, Quaternion.identity, myHex.transform);
}