public static string SaveGestures(Gesture ng, string fileName, bool drySave = false) { string gestureFolder = Path.Combine(Application.persistentDataPath, gestureFolderName); string txtFile = string.Format("{0}.txt", fileName); string gestureFileLoc = Path.Combine(gestureFolder, txtFile); if (!Directory.Exists(gestureFolder)) { Directory.CreateDirectory(gestureFolder); if (showDebugMsg) { Debug.Log("Directory not found, making one..."); } } string gestureString = GestureJSON.ToJsonString(ng); if (drySave) { if (showDebugMsg) { Debug.Log("Gesture! (Stimulate Only)"); } } else { File.WriteAllText(gestureFileLoc, gestureString); if (showDebugMsg) { Debug.Log("Saved gesture!"); } } return(gestureFileLoc); }
public void LoadExternalGestureAssets() { gestureExternalList = new List <Gesture>(); if (!loadExternalGesture) { Debug.Log("Does not load External gesture due to setting"); return; } string gestureFolder = Path.Combine(Application.persistentDataPath, gestureFolderName); if (!Directory.Exists(gestureFolder)) { //if it doesn't, create it Directory.CreateDirectory(gestureFolder); } Gesture externalGest = null; DirectoryInfo info = new DirectoryInfo(gestureFolder); FileInfo[] fileInfo = info.GetFiles(); foreach (FileInfo file in fileInfo) { string gestString = null; try { gestString = File.ReadAllText(Path.Combine(gestureFolder, file.Name)); externalGest = GestureJSON.LoadGestureJson(gestString); } catch (System.Exception e) { Debug.Log("Failed to load: " + file.Name + "; reason: " + e.Message); } if (externalGest == null) { continue; } gestureExternalList.Add(externalGest); } Debug.Log(string.Format("Loaded {0} of {1} from external files", gestureExternalList.Count, fileInfo.Length)); }
public void LoadInternalGestureAssets() { gestureInternalList = new List <Gesture>(); if (!loadInternalGesture) { Debug.Log("Does not load internal gesture due to setting"); return; } Gesture g = null; foreach (TextAsset textAsset in gestureTextAssets) { if (textAsset == null) { continue; } // Debug.Log("Trying to load: " + textAsset.name); try { g = GestureJSON.LoadGestureJson(textAsset.text); } catch (System.Exception e) { Debug.Log("Failed to load: " + textAsset.name + "; reason: " + e.Message); } if (g == null) { continue; } gestureInternalList.Add(g); } Debug.Log(string.Format("Loaded {0} of {1} internal gestures", gestureInternalList.Count, gestureTextAssets.Length)); }