yasirkula / UnitySimpleFileBrowser

A uGUI based runtime file browser for Unity 3D (draggable and resizable)
MIT License
817 stars 111 forks source link

Update FileBrowser.cs #75

Closed atomknack closed 1 year ago

atomknack commented 1 year ago

When overriding visible dialog if сurrent dialog have onCancel callback lets call it.

yasirkula commented 1 year ago

Thank you for this PR! I'd like to make this feature optional and in that case, it's possible to achieve the same thing by calling FileBrowser.HideDialog(true) prior to ShowDialog.

atomknack commented 1 year ago

Thank for your work, current onCancel already works as optional. if you pass null to it, so i don't see any reason to make it double optional at least by making some weird additional flag. If in current logic we passed meaningfull onCancel, then we want it to be called on dialog close, and hijacking current active dialog is hack, but not changes nature of previous dialog closed. Good that there such feature as HideDialog, but in case of it we cant rely just onCancel, but also on other script good nature to calling it.

yasirkula commented 1 year ago

In your case and arguably the majority of cases, calling onCancel in this situation makes sense and there's already a way to achieve this (HideDialog). If I force call onCancel inside ShowDialog and some user doesn't want it to be invoked when the dialog is replaced (as you've said, hijacking the active dialog is hack), they won't have a way to achieve this. Right now, each functionality is achievable without modifying source code or adding a weird additional flag to ShowDialog.