- Home /
Get "player value" from string
Hi!
I am working on some kind of command system for my game but I am stuck with a problem. I need to get a value from a string. Example: "login -username:". I need to be able to see what the player inputs to give them some kind of feedback. How would I do something like this?
Thanks in advance!
Comment
Answer by Fappp · May 06, 2015 at 06:01 PM
theStringEntered.IndexOf("-username"); will return 0 if -username is present, else returns 0. It's an array function, but a String is basically an array of characters!
Hope it helps! :)
http://docs.unity3d.com/ScriptReference/ArrayUtility.IndexOf.html