Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Win and Mac Native Dialogs for Unity Pro

Discussion in 'Made With Unity' started by bakno, May 9, 2012.

  1. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Native Dialogs in the Asset Store...

    http://u3d.as/content/ba-kno-games/native-dialogs/2UP



    We use this plugin in recent Charts application to open and save files, and to show warnings.

    Very easy to implement with a few lines of code per dialog which work for both Win and Mac.
     
  2. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    HI,
    I've bought your plugin but found one problem when working with MacOs standalone. The save dialog is only working in editor, not after building. The open works in both. My Unity is 3.5.2.

    Other problem is that the alert dialog always shows the Warning, but my app is localized, so i should have a parameter to change it.

    Any chance that you could implement a Activity dialog?

    Thanks,
    Fernando
     
    Last edited: Jun 15, 2012
  3. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Fernando

    On the stand alone, please make sure it contains the CocoaDialog file within the plugins folder.

    For the localized warning, you should be able to localize the message. Soon we will submit a new version to localize the title as well.

    We could implement the Activity Dialog in a future version, but no promises on the timeframe, sorry.
     
    Last edited: Jun 15, 2012
  4. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Hi!
    Thanks for the fast reply.

    Now i've checked the app file generated and realized the CocoaDialog was not there. Added and it worked.

    Thanks very much. The plugin is very useful, hope you can improve it even more. And then i guess you sould rise its price, with new features like Activity and customizable dialogs, it will be a really important plugin for many projects.

    Regards,
    Fernando
     
  5. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    Hi - I just purchased this and downloaded it. I am using a Mac. All of the dialogs work fine in the editor sample scene, EXCEPT the save dialog - it gets a Win32Exception (?). All I did was load the scene and press the button.
     
  6. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    If i am not wrong, in the pdf file that comes with the plugin it says save dialog doesn't work (in Windows) in editor mode, but works if you run the builded version.
     
  7. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    You are correct, it does say that. But I am not using Windows, I am on a Mac. Which is why it is weird that I see a Win32Exception.
     
  8. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Fernando

    We have submitted a new plugin version with the new function to change the dialog title.

    Jaimi. This error is documented as well:

     
  9. jimihay

    jimihay

    Joined:
    Mar 19, 2012
    Posts:
    15
    Does this work while the app is in full screen mode?
     
  10. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    No Jimihay. Just on windowed mode.
     
  11. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    That is not what I wrote or said. I said the save dialog does not work IN THE EDITOR. it has nothing to do with publishing. I'm on a mac, and you press the save button in the sample scene, and it fails.

    Here is what I do ON MY MAC RUNNING LION:

    1. Import your package.
    2. Delete the Microsoft.VC90.CRT folder completely. It's gone!
    3. Load the sample scene "Main Scene.Unity".
    4. Press the "Save Button".

    Win32Exception! ON MY MAC. No publishing. No windows.

    Win32Exception: ApplicationName='/Users/jaimi/Test-a-roo/Assets/Plugins/CocoaDialog.app/Contents/MacOS/CocoaDialog', CommandLine='filesave --title "Save File" --text "Save As" --with-extensions .txt --with-file TestFileName', CurrentDirectory=''
    System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start ()
    (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
    NativePanels.SaveFileDialog (System.String defaultFileName, System.String extension) (at Assets/Plugins/NativePanels.cs:198)
    TestPanels.SaveFile () (at Assets/Utils/Scripts/TestPanels.js:42)
    TestPanels.OnGUI () (at Assets/Utils/Scripts/TestPanels.js:16)
     
  12. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Jaimi

    We just tried the package on two macs running Lion and it works fine. With and without the Microsoft.VC90.CRT folder.

    What Unity version are you running? One possible explanation is that your Mono libraries are for Windows and not for Mac.
     
  13. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    I am running unity version 3.5.2f2, with the default version of Mono that ships with Unity, and my version of Lion is 10.7.4. All the dialogs work fine, except for the save dialog. I have another Monodevelop(2.4.2) installed that I do not use with Unity - it was part of MonoTouch.

    Does your software require some other version of Mono installed besides the default Unity mono? If so, and this is the problem, do we need to bundle a specific version of Mono just to use the SaveFileDialog?

    If I uncomment the section that says "This uses the bundled fileDialog but its unstable", and change the function name to "ShowSaveFileDialog", it does show the Save dialog, but I'm guessing there is some issue? If so, what could it be, seems to work fine, but then again, I'm not running every version of Lion.
     
  14. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Jaimi

    We are running the same OS version and Unity version in one of our Macs.

    The Native Dialogs plugin does not require any other version of Mono, just the one that comes with Unity.

    You can use the "ShowSaveFileDialog" but that one does not allow to change the file name on the stand alone.

    If your problems are only on the Editor, use "ShowSaveFileDialog" for the editor and the other one for the stand alone.
     
  15. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    Will you include the source to CocoaDialog.app so I can debug the crash?
     
  16. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Last edited: Jun 19, 2012
  17. TrialByFun

    TrialByFun

    Joined:
    Jun 23, 2009
    Posts:
    97
    The SaveFileDialog is also not working for me on mac, same problems as above.

    I'm calling the following method from within code;

    string path = NativePanels.SaveFileDialog("NEWLEVEL","xml");


    running this in the editor crashes * as noted in readme file *
    running this in the standalone build nothing appears at all
    I've tried adding the CocoaDialog file manually to the package, but still nothing appears appear.

    Open file dialog functions correctly.

    Mac OSX 10.7.4
    Unity 3.5.2
     
  18. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Jaimi or SBurgess. Can any of you upload a sample project or package so we can check?
     
  19. TrialByFun

    TrialByFun

    Joined:
    Jun 23, 2009
    Posts:
    97
    No need, the same happens if you start a completely fresh project then import the native dialogs package into the project and build.
     
  20. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    You are right SBurgess.

    We were able to find the culprit. Apparently the CocoaDialog.app internal files are not correctly recognized after downloaded and imported by Unity.

    Please try using the attached file.
     

    Attached Files:

  21. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    FYI - Downloading the original cocodialog.app from the link provided worked also.
     
  22. TrialByFun

    TrialByFun

    Joined:
    Jun 23, 2009
    Posts:
    97
    That works! Thanks.

    Now another problem, if I do a Windows build from the Mac, the Open dialog does not appear on the Windows PC.

    Also, is there a way you could make the CocoaDialog file automatically copy itself into the .app plugins directory so we don't have to do it manually each time?

    many thanks.
     
  23. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Please remember to add the Microsoft.VC90.CRT folder to the plugins folder on the Windows build.

    We tried using a post-process script but it did not work because the CocoaDialog file is an app. We did not spend much time trying to solve it either, so maybe in a future version.
     
    Last edited: Jun 21, 2012
  24. Radiangames

    Radiangames

    Joined:
    Sep 15, 2011
    Posts:
    16
    Any estimate on when you might be able to fix the Windows Editor issue with Open/Save dialogs? It's a lot harder to debug something that doesn't work in the editor.

    Thanks,
    Luke Schneider
    Radiangames
     
  25. Radiangames

    Radiangames

    Joined:
    Sep 15, 2011
    Posts:
    16
    Also, when I try to build in Windows (to make a Windows build), I get the following error:

    ArgumentException: The Assembly Microsoft.VisualC is referenced by msvcm90. But the dll is not allowed to be included or could not be found.
    UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache) (at C:/BuildAgent/work/d9c061b1c154f5ae/Editor/Mono/AssemblyHelper.cs:72)
    UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch) (at C:/BuildAgent/work/d9c061b1c154f5ae/Editor/Mono/AssemblyHelper.cs:107)
    UnityEditor.HostView:OnGUI()

    I'm using Unity 3.5.4f1 and Windows 7 Home Premium (SP1). The file appears to be there, but it's not recognized as a DLL. In the Unity Project display, the other two DLLs in the same folder show up with the DLL icon, but msvcm90.dll has a generic icon.

    I tried copying other versions of the DLL to the directory, and they all show up with the generic icon.

    So to recap: Neither the editor nor standalone version of this are working for me. Please help!
     
  26. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Radiangames

    Please do the following...

    - Move the folder named "Microsoft.VC90.CRT" off the Unity project.
    - When building your Windows game, copy that folder within the Plugins folder.

    This will make the plugin work on the stand alone version.
     
  27. Radiangames

    Radiangames

    Joined:
    Sep 15, 2011
    Posts:
    16
    Excellent, was able to make a build that worked as expected. Thanks for the quick reply.

    For others with the same editor issue, I'm using #if defined UNITY_EDITOR and UnityEditor.EditorUtility.SaveFilePanel for the in-editor version.

    Andres: One other suggestion for a future version would be an optional parameter to set the default directory when using OpenFileDialog or SaveFileDialog. Thanks!
     
  28. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Hi , I'm facing a few issues

    1. It will crash the Unity Editor when opening file above its current directory. So the file opened must be under the project directory in order to be opened.

    When build into Standalone, it doesn't crash but it doesn't return anything.

    2. Rthe saving part, will have and I/O write exception when file first created, but the file is created.

    U4.01 on Windows
     
  29. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    To exactly what extent is this integrated with Cocoa? Do the file dialogs support iCloud, for example? Sand boxing? And are they wrapped in proper manifests in Windows to give the dialogs the proper XP/Vista/7/8 feel?
     
  30. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi imtrobin. Native Dialogs plugin does not work well within the Unity Windows Editor, for this you can try the Unity editor methods to open the file dialogs. When building the Windows stand alone make sure you add the Microsoft.VC90.CRT folder to the plugins folder on the Windows build.

    The save dialog returns a path, and that is where the plugin ends. If you use that path to save and you receive an error, you need to check the saving method you are using.

    SevenBits. The plugin is fully integrated with Cocoa, it uses Cocoa's methods to call the dialogs. Never tried it with iCloud but it should work. However, I don't think Sandboxing works because OSX uses a separate set of secure dialogs. The windows plugin uses the Win32 native libraries, and each OS puts out the filedialog that is standard in the great mayority of applications. So it's seamless in XP/Vista/7. On Windows 8 it will work as well but only in Desktop, not Metro.
     
  31. arvie

    arvie

    Joined:
    Nov 14, 2012
    Posts:
    10
    I just bought the plugin. I tried the sample scene and I can't open any files ( .txt for example)... they are ghosted.

    I moved the Microsoft.VC90blahblahblah folder on a safe place away from the project and it wouldn't open the file.

    The Save doesn't work either.

    What am I missing here???
     
  32. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Arvie

    How are you trying the sample scene? Within Unity or as a stand alone application?

    Native Dialogs plugin does not work well within the Unity Windows Editor.
     
  33. arvie

    arvie

    Joined:
    Nov 14, 2012
    Posts:
    10
    I got it sorted out. If i take out the dots [".txt"], it works -> ["txt"].

    So the only issue left is the Save function.

    I'm running Unity 4.1.5f1 on a Mac. I tried both on the Editor and the build and I get the same errors:

    Win32Exception: ApplicationName='/Users/me/Desktop/TestEditor/Assets/Plugins/CocoaDialog.app/Contents/MacOS/CocoaDialog', CommandLine='filesave --title "Save File" --text "Save As" --with-extensions .txt --with-file TestFileName', CurrentDirectory=''
    System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start ()
    (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
    NativePanels.SaveFileDialog (System.String defaultFileName, System.String extension) (at Assets/Plugins/NativePanels.cs:198)
    TestPanels.SaveFile () (at Assets/Scripts/TestPanels.js:51)
    TestPanels.OnGUI () (at Assets/Scripts/TestPanels.js:16)
     
    Last edited: Jul 17, 2013
  34. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Arvie

    You need to learn how to pass an array of a single string element within C#.
     
  35. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Maybe this will work... new string[] {"txt"}
     
  36. arvie

    arvie

    Joined:
    Nov 14, 2012
    Posts:
    10
    Thanks. I re-phrased my post. The only issue I have left is the saving. I still get those errors and hit a dead end.

    :(
     
  37. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Arvie

    We tried the sample project using the same Unity version and it works fine.

    On the first page of this same thread I uploaded the CocoaDialog.app to solve a similar problem.

    Please try downloading it and replacing it in your project.
     
  38. arvie

    arvie

    Joined:
    Nov 14, 2012
    Posts:
    10
    Is it possible to select a folder destination without picking a file?
     
  39. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Arvie

    Currently, that is not possible.

    But we have planned to include that in a future version.
     
  40. PrisedRabbit

    PrisedRabbit

    Joined:
    Aug 14, 2012
    Posts:
    62
    Hi! I've purchased your plugin and it's working out of the box. Is it possible to set default open folder?
     
  41. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi mrbroshkin

    Unfortunately that is not possible, sorry.
     
  42. IMD

    IMD

    Joined:
    Mar 21, 2013
    Posts:
    14
    Hi just a note to clarify an issue above: Running the Demo in Editor on Mac OS, had an issue where the Load File dialog had all files greyed out (un-selectable). This was due to the demo including ‘.’ marks in the OpenFileDialog extensions array (e.g. “.txt”). As Mac OS only uses the extension without a ‘.’ mark, no files were ‘valid’ for selection. To fix this I added the line extensionStr = extensionStr.Replace(".", "”); in the Mac condition — just to be bullet proof.

    Cheers,
    IMD
     
  43. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi IMD

    Thank you for the work around.
     
    IMD likes this.
  44. IMD

    IMD

    Joined:
    Mar 21, 2013
    Posts:
    14
    Very happy to help. :) On my Christmas wish list for Santa, I have "Native Panels functionality to select and return folders rather than just files." *;)
     
  45. Batigol

    Batigol

    Joined:
    Oct 17, 2012
    Posts:
    234
    hi Bakno,
    I just purchased your plugin, it worked well on mac but can't upload to mac store
    Your plugin hasn't signed yet (NativePanels.bundle)
    Could you help us on it?
     

    Attached Files:

  46. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Hi Batigol

    I guess you need to sign the bundle yourself.
     
  47. Batigol

    Batigol

    Joined:
    Oct 17, 2012
    Posts:
    234
    How to sign it?
    We don't have your xcode source?
     
  48. Batigol

    Batigol

    Joined:
    Oct 17, 2012
    Posts:
    234
    It also ask to sign cocoa dialog too :(
     
  49. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Sorry Batigol. I thought it was possible to sign the binaries the same way the rest of the game is signed.

    If that is not possible, then I am afraid the plugin cannot be used in a MacAppStore app.
     
  50. Batigol

    Batigol

    Joined:
    Oct 17, 2012
    Posts:
    234
    But I think you could sign it with your provisioning then update as new version