yasirkula / UnitySimpleFileBrowser

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

Update FileBrowser.cs #75

Closed atomknack closed 2 years ago

atomknack commented 2 years ago

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

yasirkula commented 2 years 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 2 years 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 2 years 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.