system
1
Hello, here is my small issue.
I have a key pad that the user has to put a number to unlock the door. I made a gui.label that displays numberString (wich is just a String) if they put more then 5 digits, it displays Error! in the label.
To validate if it’s the correct code, the user push the C button on the screen and it runs that function :
function checkME()
{
if (numberString == "1234")
{
numberString += "_Access_Granted_";
openDoor.gameObject.animation.Play("door_open");
print ("Working Mademoiselle!");
}
if (numberString != "1234")
{
numberString = "_Access_Denied_";
print ("bad puppy");
}
}
The issue is, once they click the C button on the keypad, it’s suppose to Display Granted or Denied depending if it’s right or false. What happens instead, is nothing is being displayed.
Any idea?
[Edit by Berenger : Code formatting and other minor changes]
system
2
Show function how u get data.
btw… try Debug.Log(numberString) before if to see whats in string
maybe add numberString.Length to see the real length (with whitespaces if any)
u could try for loop for Debug.Log(numberString)
for(int x=0; x<numberString.Length; x++) Debug.Log(numberString);
…
but as u said … label shows nothing… i think … u didnt attach the script or the script isnt runnig.
Do you get the prints when the player press c ? Anyway, I doubt the problems is from that function, it’s just a string update. Maybe try to print that string at the end of checkMe.
Your disappearing label comes from the fact that it’s still appending “Error Code” in addition to “Access_Granted” or “Access_Denied”, and it can’t fit the whole thing in the rect width you supplied, so it’s making a new line after “Error Code”. Increasing the width of the label rect to 250 fixed it in my test.