/// <summary> /// Given a path to the raw haptic asset, generate a HapticDefinitionFile /// </summary> /// <param name="path">Path to haptic asset. Ex: C:\Haptics\my\patterns\test.pattern</param> /// <returns></returns> public HapticDefinitionFile GetHapticDefinitionFile(string path) { var result = executeToolAndWaitForResult( new ArgList() .Add("root-path", _rootPath) .Add("generate-asset", path) .Add("json") ); HapticDefinitionFile hdf = new HapticDefinitionFile(); try { object x = MiniJSON.Json.Deserialize(result); hdf.Deserialize(x as IDictionary <string, object>); return(hdf); } catch (Exception e) { #if UNITY_EDITOR UnityEngine.Debug.LogException(e); #else Console.WriteLine(e); #endif throw new HapticsLoadingException("[HLVR] Couldn't deserialize the json response for the request file path [" + path + "]"); } }
public static HapticDefinitionFile ParseHDF(string path) { try { var json = File.ReadAllText(path); IDictionary <string, object> obj = MiniJSON.Json.Deserialize(json) as IDictionary <string, object>; HapticDefinitionFile file = new HapticDefinitionFile(); file.Deserialize(obj); return(file); } catch (IOException e) { throw new HapticsLoadingException("Couldn't read the haptics asset at " + path, e); } }