I have tried following several tutorials, and searching many questions of this same exact problem. However it seems Unity keeps changing things up, so nothing shows the same, nor works the same.
In my canvas
I have an Inputfield
, in the input field settings I set it to accept integers
only. In the On End Edit(string)
I placed the GameObject with the script that contains the public void functions
. The functions do not show up in the Dynamic String
section(as most tutorials show). They show up in the Static String
section. I have tried both of these functions:
int tilesSquared;
public void StartGame(int mapSize)
{
tilesSquared = mapSize;
print("mapSize was set to "+tilesSquared);
}
public void GetMapSize(string num)
{
if(int.TryParse(num, out int result)) { tilesSquared = result; }
print("tiles squared "+ tilesSquared);
}
And neither of them work, the printed result is always 0, no matter what number I place into the field. How did Unity setup the new way to get integer as an input? Because none of the old ways work.