private void SelectAndLoadFile(object p_sender, System.Action <byte[][]> p_onLoadedCallback, bool p_isReload)
            {
                if (p_isReload)
                {
                    if (!string.IsNullOrEmpty(m_reloadLevelName))
                    {
                        LoadFile(p_sender, m_reloadLevelName, p_onLoadedCallback);
                    }
                    else
                    {
                        Debug.LogError("FileSelectionExtensionLoader: SelectAndLoadFile: no level was loaded yet, but 'p_isReload' was 'true'!");
                    }
                    return;
                }

                // load file with the level file names
                ((MonoBehaviour)p_sender).StartCoroutine(LevelDB.GetLevelListAsync((LevelFile[] p_levelFiles) =>
                {
                    if (uMyGUI_PopupManager.Instance != null)
                    {
                        // show file selection UI
                        string[] levelNames     = LevelFile.GetLevelNames(p_levelFiles);
                        string[] levelIconPaths = LevelFile.GetLevelIconPaths(p_levelFiles);
                        ((LE_PopupFileSelection)uMyGUI_PopupManager.Instance.ShowPopup(LE_FileSelectionHelpers.POPUP_NAME))
                        .SetFiles(levelNames, levelIconPaths, (int p_selectedLevelIndex) =>
                        {
                            LoadFile(p_sender, p_levelFiles[p_selectedLevelIndex].PathData, p_onLoadedCallback);
                        }, null)
                        .SetText("Load Level", "Which level do you want to load?")
                        .ShowButton("close");
                    }
                }));
            }
 private void SelectAndSaveFile(object p_sender, byte[] p_levelData, byte[] p_levelMeta, int p_removedDuplicatesCount)
 {
     // load file with the level file names
     ((MonoBehaviour)p_sender).StartCoroutine(LevelDB.GetLevelListAsync((LevelFile[] p_levelFiles) =>
     {
         if (uMyGUI_PopupManager.Instance != null)
         {
             // show file selection UI with an enter file name field
             string[] levelNames             = LevelFile.GetLevelNames(p_levelFiles);
             string[] levelIconPaths         = LevelFile.GetLevelIconPaths(p_levelFiles);
             LE_PopupFileSelection filePopup = ((LE_PopupFileSelection)uMyGUI_PopupManager.Instance.ShowPopup(LE_FileSelectionHelpers.POPUP_NAME));
             filePopup.SetFiles(levelNames, levelIconPaths,
                                // on level selected -> enter level name in the input field
                                (int p_selectedLevelIndex) =>
             {
                 filePopup.SaveInput.text = levelNames[p_selectedLevelIndex];
             },
                                // on delete button -> delete file, then refresh level list
                                (int p_deletedLevelIndex) =>
             {
                 filePopup.Hide();
                 ((MonoBehaviour)p_sender).StartCoroutine(LevelDB.Delete(p_levelFiles[p_deletedLevelIndex], (bool p_isDeleted) => SelectAndSaveFile(p_sender, p_levelData, p_levelMeta, p_removedDuplicatesCount)));
             }, false)
             .SetText("Save Level", "Enter level name or select an existing level.")
             .ShowButton("close")
             .ShowButton("save", () =>
             {
                 if (!string.IsNullOrEmpty(filePopup.SaveInput.text))
                 {
                     LevelDB.SaveFile(filePopup.SaveInput.text, p_levelData, p_levelMeta, p_removedDuplicatesCount, p_levelFiles,
                                      // update reload level name on success
                                      (string p_savedFilePath) => m_reloadLevelName = p_savedFilePath,
                                      // show file selection popup on failure
                                      () => SelectAndSaveFile(p_sender, p_levelData, p_levelMeta, p_removedDuplicatesCount));
                 }
                 else
                 {
                     ((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup(LE_FileSelectionHelpers.POPUP_TEXT)).SetText("Save Level", "The level name cannot be empty!").ShowButton("ok", () =>
                     {
                         SelectAndSaveFile(p_sender, p_levelData, p_levelMeta, p_removedDuplicatesCount);
                     });
                 }
             });
         }
     }));
 }