/// <summary> /// Generic function for fetching a Wwise object with custom return options. /// </summary> /// <typeparam name="T"> Type of the object to be deserialized from the response.</typeparam> /// <param name="guid">GUID of the target object.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="callback">Function accteping a list of T objects.</param> public static void GetWwiseObject <T>(System.Guid guid, ReturnOptions options, GetResultListDelegate <T> callback) { GetWwiseObjects(new List <System.Guid>() { guid }, options, callback); }
/// <summary> /// Get the children of a given object. /// </summary> /// <param name="guid">GUID of the target object.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="callback">Function accepting a list of WwiseObjectInfo.</param> public static void GetChildren <T>(System.Guid guid, ReturnOptions options, GetResultListDelegate <T> callback) { if (guid == System.Guid.Empty) { return; } var args = new WaqlArgs($"from object \"{guid:B}\" select children orderby path"); QueueCommandWithReturnWwiseObjects(args, options, callback); }
/// <summary> /// Get the WwiseObjectInfo for the project. /// </summary> /// <param name="callback">Function accepting a list of WwiseObjectInfo. The first element of the list will be the project info.</param> /// <param name="options">Specifies which object properties to include in the response</param> public static void GetProject <T>(GetResultListDelegate <T> callback, ReturnOptions options) { var args = new WaqlArgs($"from type {WaapiKeywords.PROJECT}"); QueueCommandWithReturnWwiseObjects(args, options, callback); }
/// <summary> /// Composes a WAQL "search" request based on the parameters and enqueues a WAAPI command. /// Passes the list of WwiseObjectInfo containing the search results to the callback /// </summary> /// <param name="searchString">Characters to search for.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="objectType">An optional object type used to filter search results.</param> /// <param name="callback">Function accepting a list of WwiseObjectInfo.</param> public static void Search <T>(string searchString, WwiseObjectType objectType, ReturnOptions options, GetResultListDelegate <T> callback) { WaqlArgs args; if (objectType == WwiseObjectType.None) { args = new WaqlArgs($"from search \"{searchString}\" orderby path"); } else { args = new WaqlArgs($"from search \"{searchString}\" where type=\"{WaapiKeywords.WwiseObjectTypeStrings[objectType]}\" orderby path"); } QueueCommandWithReturnWwiseObjects(args, options, callback); }
/// <summary> /// Composes a WAQL "from object" request based on the parameters and enqueues a WAAPI command. /// Passes the list of WwiseObjectInfo containing the results to the callback /// </summary> /// <param name="identifier">Can bethe target object GUID or path within the heirarchy.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="depth">Depth of descendants to fetch. If -1, fetches all descendants.</param> /// <param name="callback">Function accepting a list of WwiseObjectInfo.</param> public static void GetWwiseObjectAndDescendants <T>(string identifier, ReturnOptions options, int depth, GetResultListDelegate <T> callback) { WaqlArgs args; if (depth > 0) { string selectString = System.String.Join(" ", ArrayList.Repeat(" select this, children", depth).ToArray()); args = new WaqlArgs($"from object \"{identifier}\" {selectString} orderby path"); } else { args = new WaqlArgs($"from object \"{identifier}\" select descendants orderby path"); } QueueCommandWithReturnWwiseObjects(args, options, callback); }
/// <summary> /// Enqueues a waapi comand to fetch the specified object and all of its descendants in the heirarchy to a specified depth. /// Passes the list of WwiseObjectInfo containing the specified object and descendants to the callback. /// </summary> /// <param name="guid">GUID of the target object.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="depth"> Depth of descendants to fetch. If -1, fetches all descendants.</param> /// <param name="callback">Function accepting a list of WwiseObjectInfo.</param> public static void GetWwiseObjectAndDescendants <T>(System.Guid guid, ReturnOptions options, int depth, GetResultListDelegate <T> callback) { GetWwiseObjectAndDescendants(guid.ToString("B"), options, depth, callback); }
/// <summary> /// Enqueues a waapi command to fetch the specified object and all of its ancestors in the heirarchy. /// Passes the list of WwiseObjectInfo containing the specified object and ancestors to the callback. /// </summary> /// <param name="guid">GUID of the target object.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="callback">Function accepting a list of WwiseObjectInfo.</param> public static void GetWwiseObjectAndAncestors <T>(System.Guid guid, ReturnOptions options, GetResultListDelegate <T> callback) { var args = new WaqlArgs($"from object \"{guid:B}\" select this, ancestors orderby path"); QueueCommandWithReturnWwiseObjects(args, options, callback); }
/// <summary> /// Generic function for fetching a list of Wwise objects with custom return options. /// </summary> /// <typeparam name="T"> Type of the object to be deserialized from the response.</typeparam> /// <param name="guids">GUIDs of the target objects.</param> /// <param name="options">Specifies which object properties to include in the response</param> /// <param name="callback">Function accteping a list of T objects.</param> public static void GetWwiseObjects <T>(List <System.Guid> guids, ReturnOptions options, GetResultListDelegate <T> callback) { string guidString = ""; foreach (var guid in guids) { guidString += $"{guid:B} ,"; } var args = new WaqlArgs($"from object \"{guidString}\" "); QueueCommandWithReturnWwiseObjects(args, options, callback); }
/// <summary> /// Enqueues a command with a payload that desirializes the list of wwise objects from the response. /// </summary> /// <param name="args"></param> /// <param name="options"></param> /// <param name="callback"></param> public static void QueueCommandWithReturnWwiseObjects <T>(WaqlArgs args, ReturnOptions options, GetResultListDelegate <T> callback) { waapiCommandQueue.Enqueue(new WaapiCommand( async() => { var result = await WaapiClient.Call([email protected], args, options); var ret = UnityEngine.JsonUtility.FromJson <ReturnWwiseObjects <T> >(result); callback.Invoke(ret.@return); })); }