Hi,
I'm developing a slideshow app of sorts.
Users add a photo and an audio clip for each slide and then entire slideshow is saved to disk.
I am using ES.Save and ES2.Load and everything is working. (using ES2.Load<AudioClip> and ES2.Load<Texture2d> respectively where needed)
The problem is loading an entire slideshow take a bit of time (15-20 seconds on slower devices) and I would like to put on some loading screen animation while that is happening - but I can't seem to find a way to "check" when the actual loading is finished.
Is there a way to get a callback?
Any suggestions on what to do?
here are my methods using ES2:
public Texture2D loadPageImage(string currentBookFileName, int pageIndex){
Debug.Log("<< Load Texture Method Began >>");
string bookFolderPath = currentBookFileName;
string pageFolderPath = Path.Combine (bookFolderPath, "Page_" + pageIndex.ToString ("000"));
string photoFileName = "pagePhoto.R55";
string pathToFile = Path.Combine (pageFolderPath, photoFileName);
Debug.Log ("pathToFile: " + pathToFile);
if (ES2.Exists (pathToFile)) {
Debug.Log ("## Load Texture Method completed ##");
return ES2.Load<Texture2D> (pathToFile);
} else {
Debug.Log ("Texture path doesn't exist: " + pathToFile);
return null;
}
}
public AudioClip loadPageAudio(string currentBookFileName, int pageIndex){
Debug.Log("<< Load Audio Method Began >>");
string bookFolderPath = currentBookFileName;
string pageFolderPath = Path.Combine (bookFolderPath, "Page_" + pageIndex.ToString ("000"));
string audioFileName = "pageAudio.R55";
string pathToFile = Path.Combine (pageFolderPath, audioFileName);
Debug.Log ("pathToFile: " + pathToFile);
if (ES2.Exists (pathToFile)) {
Debug.Log ("## Load Audio Method completed ##");
return ES2.Load<AudioClip> (pathToFile);
} else {
Debug.Log ("Audio-File path doesn't exist: " + pathToFile);
return null;
}
}
And here's the main loop using these methods:
DirectoryInfo dir = new DirectoryInfo(Path.Combine(Application.persistentDataPath, currentBookFileName));
DirectoryInfo[] pagesInBook = dir.GetDirectories("Page_*");
lastPageToLoad = pagesInBook.Length-1;
Debug.Log ("setting lastPageToLoad to: " + lastPageToLoad);
screenBook.pages.Clear();
int stash = pageIndex;
pageIndex = 0;
foreach (DirectoryInfo pageFolder in pagesInBook) {
SinglePage newPage = new SinglePage ();
newPage.texture = savemanager.loadPageImage (currentBookFileName, pageIndex);
newPage.clip = savemanager.loadPageAudio (currentBookFileName, pageIndex);
screenBook.pages.Add (newPage);
pageIndex++;
}
pageIndex = stash;
I'd appreciate any help I can get, thanks in advance,
David
Es2 Save/Load Callback?
Re: Es2 Save/Load Callback?
Hi there,
Easy Save runs synchronously, so it is completed when the method returns.
If you wish to run Easy Save asynchronously you should run it in a separate thread.
All the best,
Joel
Easy Save runs synchronously, so it is completed when the method returns.
If you wish to run Easy Save asynchronously you should run it in a separate thread.
All the best,
Joel