Search Unity

MessageBox

Discussion in 'Assets and Asset Store' started by CorruptedHeart, Feb 7, 2012.

  1. CorruptedHeart

    CorruptedHeart

    Joined:
    May 4, 2010
    Posts:
    379
    MessageBox the Unity GUI implementation of .NET's MessageBox class.

    It supports most of the MessageBox.Show() (http://msdn.microsoft.com/en-us/library/dtkc6h4c.aspx) methods except the ones to do with IWin32Window and Help. However, it comes with selectable buttons and icons. It also supports all the DialogResults.

    The main difference between this and the .NET version is that this requires the use of callbacks for handling the DialogResults.

    .NET Version:
    Code (csharp):
    1. var result = MessageBox.Show("This is the text", "This is the Title", MessageBoxButtons.YesNo);
    2. if(result == DialogResult.Yes)
    3. {
    4.    Console.Write("Yes");
    5. }
    6. else
    7. {
    8.    Console.Write("No");
    9. }
    MessageBox Version:
    Code (csharp):
    1. void Start()
    2. {
    3.    MessageBox.Show(HandleMessage,"This is the text", "This is the Title", MessageBoxButtons.YesNo);
    4. }
    5.  
    6. void HandleMessage(DialogResult result)
    7. {
    8.    if(result == DialogResult.Yes)
    9.    {
    10.       Console.Write("Yes");
    11.    }
    12.    else
    13.    {
    14.       Console.Write("No");
    15.    }
    16. }

    In-game​

    Version: 1.0
    Unity Version: 3.4.1
    Source Code: C#
    Asset Store Link: http://u3d.as/content/corrupted-smile-studio/message-box/2Eo
    Web Player Demo
    Price: $5

    Regards,
    Garth
     
    Last edited: Feb 16, 2012
  2. CorruptedHeart

    CorruptedHeart

    Joined:
    May 4, 2010
    Posts:
    379
    MessageBox is now available on the Asset Store.
     
  3. undefreference

    undefreference

    Joined:
    Mar 16, 2013
    Posts:
    5
    How do you Import DialogResult ????
     
  4. CorruptedHeart

    CorruptedHeart

    Joined:
    May 4, 2010
    Posts:
    379
    DialogResult is within the CorruptedSmileStudio.MessageBox namespace, so you can either use
    Code (csharp):
    1. CorruptedSmileStudio.MessageBox.DialogResult
    or add
    Code (csharp):
    1. using CorruptedSmileStudio.MessageBox;
    then use it as
    Code (csharp):
    1. void MessageBoxCallback(DialogResult result)
    2. { // code
    3. }
    Are you trying to access this from C# or UnityScript?

    Regards,
    Garth
     
  5. undefreference

    undefreference

    Joined:
    Mar 16, 2013
    Posts:
    5
    Hey,
    i am using Unity3d.
    But how i get The CorruptedSmileStudio package to use CorruptedSmileStudio.MessageBox namespace ?
    I dont have buy it!
     
  6. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    Bought it yesterday, seems not working in the latest Unity.
     
  7. CorruptedHeart

    CorruptedHeart

    Joined:
    May 4, 2010
    Posts:
    379
    Which version of Unity exactly? Did you place the MessageBox component on a gameObject?