1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

Chat Window

Discussion in 'Scripting' started by Vimalakirti, Oct 22, 2009.

  1. Vimalakirti

    Vimalakirti

    Joined:
    Oct 12, 2009
    Posts:
    753
    Dear Friends,

    I'm not sure if this should be here or in GUI, but it's definitely a scripting problem and I'm stuck.

    I'm trying to make a chat entry window in the style of WoW, activated and de-activated by pressing Return. I want to press return, have a line entry window appear with the cursor activated, type in a line, press enter again, then process that text in a separate function ("TextEnter").

    This is the script in my character controller:
    Code (csharp):
    1.  
    2. public var commandLine:String = "";
    3. function OnGUI () {
    4. entering = GetComponent(TextEnter);
    5. if (Event.current.Equals (Event.KeyboardEvent ("return")) )
    6.             {
    7.          commandLine = GUI.TextField (Rect (10, 80, 600, 20), commandLine, 25);    
    8.          if (Event.current.Equals (Event.KeyboardEvent ("return")) )
    9.          {
    10.             print("going to the function");
    11.             entering.EnterText();
    12.          }
    13.          }
    14. }  

    and this is the script "TextEnter" with the function "EnterText":

    Code (csharp):
    1. function EnterText(){
    2.             print("Executing function TextEnter!");
    3. };
    What happens is this:
    In game, debug is quiet at first. When I press enter, debug says "going to the function" and "Executing function TextEnter!" both together immediately. The text entry window does not appear.

    Eventually, I'll bang my head against my keyboard enough so that I'll either pass out, or it will break, so the problem will get solved eventually.

    Thanks!
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    see your other thread