Unity Community


Results 1 to 2 of 2

Thread: Chat Window


  1. Location
    Austin, TX
    Posts
    751

    Chat Window

    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:  
    1. public var commandLine:String = "";
    2. function OnGUI () {
    3. entering = GetComponent(TextEnter);
    4. if (Event.current.Equals (Event.KeyboardEvent ("return")) )
    5.             {
    6.          commandLine = GUI.TextField (Rect (10, 80, 600, 20), commandLine, 25);    
    7.          if (Event.current.Equals (Event.KeyboardEvent ("return")) )
    8.          {
    9.             print("going to the function");
    10.             entering.EnterText();
    11.          }
    12.          }
    13. }


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

    Code:  
    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. Location
    Zürich, Switzerland
    Posts
    26,572
    see your other thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •