user interface - how can i make the unity gui window dragable -


i trying make window dragable i'm making multiplayer game , status shown has window

public bool finishsession = false; public bool showhelp = false;  private arraylist messages = new arraylist(); private string currenttime = ""; private string newmessage = ""; private vector2 windowscrollposition;  private smartfox smartfox; private guistyle windowstyle; private guistyle usereventstyle; private guistyle systemstyle;  public rect rctwindow; public float windowpanelposx; public float windowpanelposy; public float windowpanelwidth; public float windowpanelheight;  public statuswindow() {     smartfox = smartfoxconnection.connection; }  public void addsystemmessage(string message) {     messages.add(new statusmessage(statusmessage.statustype.system, message));     windowscrollposition.y = 100000; }  public void addstatusmessage(string message) {     messages.add(new statusmessage(statusmessage.statustype.status, message));     windowscrollposition.y = 100000; }  public void addtimemessage(string message) {     //messages.add(new statusmessage(statusmessage.statustype.time, message));     //windowscrollposition.y = 100000;     currenttime = message; }  public void draw(float panelposx, float panelposy, float panelwidth, float panelheight) {     windowpanelposx = panelposx;     windowpanelposy = panelposy;     windowpanelwidth = panelwidth;     windowpanelheight = panelheight;      // status history panel     rctwindow = new rect(windowpanelposx, windowpanelposy, windowpanelwidth, windowpanelheight);     rctwindow = gui.window (1, rctwindow, domywindow, "interreality portal status", gui.skin.getstyle("window"));     gui.dragwindow(); }  void domywindow(int windowid) {        windowstyle = gui.skin.getstyle("windowstyle");     systemstyle = gui.skin.getstyle("systemstyle");     usereventstyle = gui.skin.getstyle("usereventstyle");      //cuadro blanco          guilayout.beginarea (new rect (10, 25, windowpanelwidth - 20, windowpanelheight - 70), gui.skin.getstyle ("whitebox"));         guilayout.beginvertical ();          //general information area         if (smartfox != null && smartfox.lastjoinedroom != null) {             guilayout.label ("current room: " + smartfox.lastjoinedroom.name);             //if (currentgamestate == gamestate.running ) {             //guilayout.label(trisgameinstance.getgamestatus()); //acpr             //}          }            guilayout.label ("activity: 1 - construct");         guilayout.label ("elapsed time: " + currenttime);          //message area         windowscrollposition = guilayout.beginscrollview (windowscrollposition);         foreach (statusmessage message in messages) {             drawstatusmessage (message);         }                            guilayout.endscrollview ();         //cierra cuadro blanco         guilayout.endvertical ();         guilayout.endarea ();           //logout area         guilayout.beginarea (new rect (windowpanelwidth / 2, windowpanelheight - 70 + 30, windowpanelwidth / 2 + 10, 30));//, gui.skin.getstyle("whitebox"));         guilayout.beginhorizontal ();         if (guilayout.button ("help", gui.skin.getstyle ("greenbtn"))) {             showhelp = true;         }         guilayout.space (10);         if (guilayout.button ("end session", gui.skin.getstyle ("redbtn"))) {             finishsession = true;         }          guilayout.endhorizontal ();         guilayout.endarea ();      gui.dragwindow(); }  private void drawstatusmessage(statusmessage message) {     guilayout.beginhorizontal();     guilayout.space(5);     switch (message.getstatustype()) {     case statusmessage.statustype.system:         guilayout.label(message.getmessage(), systemstyle);         break;     case statusmessage.statustype.status:         guilayout.label(message.getmessage(), windowstyle);         break;     case statusmessage.statustype.time:         guilayout.label(message.getmessage(), usereventstyle);         break;     default:         // ignore , dont print         break;     }      guilayout.flexiblespace();     guilayout.endhorizontal();     guilayout.space(1);     gui.dragwindow(); }  class statusmessage {     public enum statustype {         ignore = 0,         system,         status,         time,     };     private statustype type;     private string message;      public statusmessage() {         type = statustype.ignore;         message = "";     }      public statusmessage(statustype type, string message) {         this.type = type;         this.message = message;     }      public statustype getstatustype() {         return type;     }      public string getmessage() {         return message;     } } 

}

but when i'mm trying drag window doesn't drag

i tried simpler class jnothing works fine when call window doesn't drag

statuswindow statuswindow = null; void start(){ statuswindow = new statuswindow(); } public rect windowrect = new rect(20, 20, 120, 50);     void ongui() {         windowrect = gui.window(0, windowrect, domywindow, "my window");     statuswindow.draw (100, 100, 100, 100);     }      void domywindow(int windowid) {         gui.button(new rect(10, 20, 100, 20), "can't drag me");         gui.dragwindow();     } 

if knows unity gui can great


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -