- Home /
 
iphone keyboard ..
private string inputText = "text"; private iPhoneKeyboard keyboard_; // Updates button's text while user is typing
 
               void OnGUI() { if (GUI.Button(new Rect(0, 10, 200, 32), inputText)) keyboard_ = iPhoneKeyboard.Open(inputText);
 
                if(keyboard_)
     inputText = keyboard_.text;
 }
  
               } 
How can i convert the following line to C# : if(keyboard_)??? Right now i get this error: Cannot implicitly convert type UnityEngine.iPhoneKeyboard' tobool' Thanks
Answer by Peter G · Apr 28, 2011 at 12:04 AM
C# won't implicitly convert that to a boolean operation. In javascript, the compiler assumes you mean that you want to check if the object is null or has a reference.
In C#, you have to be more explicit in telling it what you meant.
You have to do:
 if(keyboard_ != null) {
      inputText = keyboard_.text;
 }
 
              Your answer
 
             Follow this Question
Related Questions
Quiz Scoreboard 2 Answers
Getting list music array 1 Answer
Login String to Bool Errors 1 Answer
[Closed] Getting CS0029 error when I try to check position of an object 1 Answer
Compile Errors for Script 1 Answer