public static void SaveLevel(string p_levelDataFilePath, string p_levelIconFileName, byte[] p_levelData, byte[] p_levelMeta, int p_removedDuplicatesCount) { // info popup System.Action <string> infoPopup = (string p_infoText) => { if (uMyGUI_PopupManager.Instance != null) { if (p_removedDuplicatesCount > 0) { p_infoText += "\n'" + p_removedDuplicatesCount + "' duplicate object(s) removed before saving\n(duplicate = same: object, position, rotation, scale)."; } ((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup(POPUP_TEXT)).SetText("Level Saved", p_infoText).ShowButton("ok"); } }; // save level icon as png LE_SaveLoad.LevelMetaData loadedMeta = LE_SaveLoad.LoadLevelMetaFromByteArray(p_levelMeta, true); if (loadedMeta.Icon != null) { Texture2D downScaledIcon = LE_FileSelectionHelpers.DownscaleTexture(loadedMeta.Icon, 255, 128); // save to file string path = Path.Combine(Application.persistentDataPath, p_levelIconFileName); // need to use own implementation of SaveToFile to keep backwards compatibility with MRLE v1.31 (had no UtilityPlatformIO.SaveToFile(..., bytes[])) LE_FileSelectionHelpers.SaveToFile(path, downScaledIcon.EncodeToPNG()); Object.Destroy(loadedMeta.Icon); Object.Destroy(downScaledIcon); } // save level infoPopup(ExampleGame_LoadSave.SaveByFilePath(p_levelDataFilePath, p_levelData, p_levelMeta)); }
private void LoadFile(object p_sender, string p_filePath, System.Action <byte[][]> p_onLoadedCallback) { m_reloadLevelName = p_filePath; // show a loading message if (uMyGUI_PopupManager.Instance != null) { uMyGUI_PopupManager.Instance.ShowPopup(LE_FileSelectionHelpers.POPUP_LOADING); } // try load level ((MonoBehaviour)p_sender).StartCoroutine(ExampleGame_LoadSave.LoadRoutineByFilePath(p_filePath, p_onLoadedCallback)); }