Search Unity

Using Windows dialolg boxes

Discussion in 'Scripting' started by TheAlchemist42, Jul 15, 2009.

  1. TheAlchemist42

    TheAlchemist42

    Joined:
    Apr 17, 2008
    Posts:
    68
    I have a project which is only for use on Windows (several versions of Windows, but not Mac). I am trying to get a nice built in modal dialog box to use for various purposes in my Unity program.

    Is this possible? I have tried the obvious (to me) which is using System.Windows.MessageBox.Show(), but it will not allow that, saying:

    'Windows' is not a member of 'System'.

    Is there another way to do this? I would really prefer not to use Unity's GUI to make all these dialogs, since I really want them themed to match the user's system. I do not want to build custom dialogs that will be non-standard-looking. I want people with XP to see an XP dialog and Vista to see a Vista dialog.

    Is this possible or am I doing something wrong?
     
  2. TomDOW2

    TomDOW2

    Joined:
    Jun 26, 2009
    Posts:
    7
    I do not know anything about the command that you are useing but could the windows format be called something else? This is probbobly wrong but if you are useing the system class from .net there may be help on the microsoft website. If not try .net; it is made by microsoft so as long as it works with unity it may be able to make the diologe box. If you do get .net to work please post how.
     
  3. TheAlchemist42

    TheAlchemist42

    Joined:
    Apr 17, 2008
    Posts:
    68
    System.Windows is the name of the .Net class that controls dialog boxes. In fact, I got it right out of the MSDN support site at microsoft.com. The problem is that the .Net command should work in Unity (I think), but doesn't.
     
  4. shaKu

    shaKu

    Joined:
    May 19, 2009
    Posts:
    28
    You said it; that is a .NET command which is used in the Microsoft .NET Framework. Unity runs an implementation of Mono which probably does not implement this same method. You can look through the mono documentation at http://www.go-mono.com/docs/
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Check out the mono docs on correspondong Mono.xxx functions (and ensure that they are present in Mono 1.2.5, because thats what Unity uses).

    Many of the things related to System.Windows and System.Forms are MS .NET only at least it has a very good chance to be like that.
     
  6. Shaneo

    Shaneo

    Joined:
    Apr 2, 2009
    Posts:
    50
    To use native dialogs you'll have to use C/C++ and call

    Code (csharp):
    1.  
    2. int MessageBox( HWND hWnd,
    3.     LPCTSTR lpText,
    4.     LPCTSTR lpCaption,
    5.     UINT uType
    6. );
    7.  
    These message boxes will block until the user makes a selection, so depending on where you call it from it may pause unity until it returns.