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?
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.
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.
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/
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.
To use native dialogs you’ll have to use C/C++ and call
int MessageBox( HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType
);
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.