public void Log(NfdResult result, string outPath, string[] outPaths)
        {
            switch (result)
            {
            case NfdResult.NFD_OKAY:
                if (outPaths != null)
                {
                    Debug.LogFormat("[NFD] Selected multiple ‹{0}›", string.Join("› ‹", outPaths));
                }
                else
                {
                    Debug.LogFormat("[NFD] Selected ‹{0}›", outPath);
                }
                break;

            case NfdResult.NFD_ERROR:
                var err = NativeFileDialog.GetError();
                if (!string.IsNullOrEmpty(err))
                {
                    Debug.LogError("[NFD] Error: " + err);
                }
                else
                {
                    Debug.LogError("[NFD] Error: Unknown Reason");
                }
                break;

            case NfdResult.NFD_CANCEL:
                Debug.Log("[NFD] Cancelled");
                break;
            }
        }
Beispiel #2
0
        public void Show()
        {
            string outPath = null;

            string[]  outPaths = null;
            NfdResult result   = NfdResult.NFD_CANCEL;

            switch (fileDialogType)
            {
            case FileDialogType.Open:
                if (!allowOpenMultiple)
                {
                    result = NativeFileDialog.OpenDialog(filterList, defaultPath, out outPath);
                }
                else
                {
                    result = NativeFileDialog.OpenDialogMultiple(filterList, defaultPath, out outPaths);
                    if (outPaths != null && outPaths.Length > 0)
                    {
                        outPath = outPaths[0];
                    }
                }
                break;

            case FileDialogType.Folder:
                result = NativeFileDialog.PickFolder(defaultPath, out outPath);
                break;

            case FileDialogType.Save:
                result = NativeFileDialog.SaveDialog(filterList, defaultPath, out outPath);
                break;
            }

            if (onResult != null)
            {
                onResult.Invoke(result, outPath, outPaths);
            }
        }