Hello Im trying to create a calculator but am having some issues finding out if there is already a decimal point in the in the textField? and i’ll need to do the same for the other characters +, -, *, etc…
I keep getting an error “Contains is not a member of String” So Im having difficulty finding a solution?
var textFieldString = "";
private var number0 : int = 0;
private var decimal : String = ".";
function OnGUI()
{
if (GUILayout.Button ("num 0", GUILayout.Width(50)))
{
textFieldString = textFieldString + number0.ToString();
}
if (GUILayout.Button ("."))
{
if(textFieldString.Contains(dec))
{
return;
}
else
{
textFieldString = textFieldString + dec.ToString();
}
}
}
Oh… one more thing is there a way for the text to be displayed from right hand side instead of the left hand side? in the textField?
Thanks for any help! I think creating a calculator is going to be one tough thing to learn 
I’m not getting the same error, but you might try Importing System " import System; " at the top (so that you can use the .net classes).
You do have a naming issue though, you called decimal “decimal” at the top, but “dec” at the bottom.
and you don’t need the .ToString() in
since it’s already a string.
As for the text alignment in the text field the only way I know of is to create a new GUISkin in your project and assign it to this script in the inspector, and set the GUI.skin to that. If you find a way to do this entirely in code let me know, please! but until Unity 3.5 or latter (if they don’t finish the GUI part in time) just have to stick to the GUI Skin files.
Thanks for the reply 
I tried writing “import System;” at the top but get the same error? Are you getting any errors at all?
Ahh yes I forgot to change dec to decimal for this post I just wanted to make it easier for the reader to read but had it correct in my script 
Thanks for the tip on Not needing the .ToString(); at the end, thats cool.
I’ll add the GUI Skin as well another great tip!
I just need to figure out how to solve the .Contains issue with the String?
I did find this post (http://forum.unity3d.com/threads/25878-Searching-a-string-for-a-string) but it seems like a complicated way to go and seems I might have to create many unnecessary variables?? for the For loop and somehow detect if theres a decimal??? Just dont seem right?
Unless theres another way to go Id love to hear any suggestions.
Well I’m not getting the same error on mine, copied the script exactly how you have it, works. I even use Substring in one of my saving/loading scripts.
Almost want to ask what version are you on? Especially since I don’t have the error (am on 3.4) and JTBentley had the error in 2009. Though I don’t know that String has changed much.
You wouldn’t need a for loop for it though, you could I guess, if you wanted to convert it to an array of characters, but really thats all a string is so theres no point.
Thank you very much! 
I was using Unity iPhone 1.7 and have upgraded to Unity 3.4 which seems to work now and the error has gone 
I seriously appreciate all of the advice its greatly appreciated!!!
I use a formula for input that goes (N1*10)+n
This is Current Number * 10 (this simply makes our number correct when adding the next number) + new number
i.e if we type 14
1
(1*10) +4 = 14