SlamSettings LoadFile() { SlamSettings sl = null; string ret = null; Task <Task> task = Task <Task> .Factory.StartNew( async() => { try { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; //C:\Users\awonn\AppData\Local\Packages\19034vSlam.org.vSlam3DPro_1h1swmnfvff8a\LocalState var f = await storageFolder.TryGetItemAsync(dataFileName); if (f != null) { Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync(dataFileName); ret = await Windows.Storage.FileIO.ReadTextAsync(sampleFile); await Task.Factory.StartNew(() => sl = Newtonsoft.Json.JsonConvert.DeserializeObject <SlamSettings>(ret)); } } catch (Exception x) { } }); task.Wait(); task.Result.Wait(); return(sl); }
virtual public void LoadData() { #if !UNITY_WSA || UNITY_EDITOR string tfile = Application.persistentDataPath + "/" + dataFileName; if (File.Exists(tfile)) { FileStream file = null; try { BinaryFormatter bf = new BinaryFormatter(); file = File.Open(tfile, FileMode.Open); slamSettings = (SlamSettings)bf.Deserialize(file); } catch (Exception x) { Debug.Log(x.Message); } finally { if (file != null) { file.Close(); } } } #endif }
override public void LoadData() { #if UNITY_WSA && !UNITY_EDITOR try { var localSlamSettings = LoadFile(); if (localSlamSettings != null) { slamSettings = localSlamSettings; } } catch (Exception) { }; if (slamSettings == null) { slamSettings = new SlamSettings(); } if (isOpaque) { name = CallingDevices.MR.ToString(); } #endif }