Exemplo n.º 1
0
 /// <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);
 }
Exemplo n.º 2
0
    /// <summary>
    /// Subscribe to WAAPI topic. Refer to WAAPI reference documentation for a list of topics and their options.
    /// Creates and sends a WAAPI command to subscribe to the topic.
    /// </summary>
    /// <param name="subscription">SubscriptionInfo object containing the topic URI and the message handling callback.</param>
    /// <returns>Updated SubscriptionInfo object containing the subscription ID (uint). </returns>
    private static async Task <SubscriptionInfo> SubscribeAsync(SubscriptionInfo subscription)
    {
        var  options = new ReturnOptions(new string[] { "id", "parent", "name", "type", "childrenCount", "path", "workunitType" });
        uint id      = await WaapiClient.Subscribe(subscription.Uri, options, subscription.Callback);

        subscription.SubscriptionId = id;
        return(subscription);
    }
Exemplo n.º 3
0
 /// <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);
     }));
 }
Exemplo n.º 4
0
    /// <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);
    }
Exemplo n.º 5
0
    private static async Task <List <WwiseObjectInfo> > GetProjectInfo()
    {
        var args    = new WaqlArgs($"from type {WaapiKeywords.PROJECT}");
        var options = new ReturnOptions(new string[] { "filePath" });

        var result = await WaapiClient.Call([email protected], args, options);

        var ret = UnityEngine.JsonUtility.FromJson <ReturnWwiseObjects>(result).@return;

        return(ParseObjectInfo(ret));
    }
 public SearchCommand(MessageBus messageBus, ReturnOptions returnOptions = SearchQuery.DefaultReturnOptions, bool broadcastSearch = true, Func <SearchQuery, Task> queryCallback = null, Func <SearchResults, Task> resultsCallback = null)
 {
     MessageBus = messageBus ?? throw new ArgumentNullException("messageBus");
     MessageBus.Subscribe <ServerSettingsChangedMessage>(m => CommandManager.InvalidateRequerySuggested());
     ExecuteCallback    = new Func <object, Task>(ExecuteSearch);
     CanExecuteCallback = InternalCanExecuteCallback;
     ErrorCallback      = InternalErrorCallback;
     ReturnOptions      = returnOptions;
     BroadcastSearch    = broadcastSearch;
     QueryCallback      = queryCallback;
     ResultsCallback    = resultsCallback;
 }
Exemplo n.º 7
0
    /// <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);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Uses a waapi call to get the SoundBank's generated bank path, then opens the containing folder in the system's file browser.
    /// </summary>
    /// <param name="guid">GUID of the object to be found.</param>
    /// <returns>Awaitable Task.</returns>
    private static async Task OpenSoundBankInExplorerAsync(System.Guid guid)
    {
        var args    = new WaqlArgs($"from object \"{guid:B}\"");
        var options = new ReturnOptions(new string[] { "soundbankBnkFilePath" });
        var result  = await WaapiClient.Call([email protected], args, options);

        var ret      = UnityEngine.JsonUtility.FromJson <ReturnWwiseObjects>(result);
        var filePath = ret.@return[0].soundbankBnkFilePath;

#if UNITY_EDITOR_OSX
        filePath = AkUtilities.ParseOsxPathFromWinePath(filePath);
#endif
        UnityEditor.EditorUtility.RevealInFinder(filePath);
    }
Exemplo n.º 9
0
    /// <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);
    }
Exemplo n.º 10
0
    /// <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);
    }
Exemplo n.º 11
0
 public BeginSearchMessage(ReturnOptions returnOptions, bool isPaging = false)
 {
     ReturnOptions = returnOptions;
     IsPaging      = isPaging;
 }
    public static IEnumerable <string> SafeEnumerateFileAndDirNames(this string path, string filePattern, string dirPattern, SearchOption searchOpt = SearchOption.TopDirectoryOnly, ReturnOptions returnOpt = ReturnOptions.ReturnBoth)
    {
        var searchQueue = new Queue <string>()
        {
            path
        };

        while (searchQueue.Count > 0)
        {
            var cdn = searchQueue.Dequeue();

            IEnumerable <string> cdiFiles = null;
            if (returnOpt.HasFlag(ReturnOptions.ReturnFiles))
            {
                try {
                    cdiFiles = Directory.EnumerateFiles(cdn, filePattern, SearchOption.TopDirectoryOnly);
                }
                catch (Exception) {
                }

                if (cdiFiles != null)
                {
                    foreach (var filename in cdiFiles)
                    {
                        yield return(filename);
                    }
                }
            }

            if ((!returnOpt.HasFlag(ReturnOptions.ReturnFiles) || cdiFiles != null) && (returnOpt.HasFlag(ReturnOptions.ReturnDirectories) || searchOpt == SearchOption.AllDirectories))       // skip if file enumeration failed
            {
                IEnumerable <string> cdiDirs = null;
                try {
                    cdiDirs = Directory.EnumerateDirectories(cdn, dirPattern, SearchOption.TopDirectoryOnly);
                }
                catch (Exception) {
                }

                if (cdiDirs != null)
                {
                    foreach (var dirname in cdiDirs)
                    {
                        if (searchOpt == SearchOption.AllDirectories)
                        {
                            searchQueue.Enqueue(dirname);
                        }

                        if (returnOpt.HasFlag(ReturnOptions.ReturnDirectories))
                        {
                            yield return(dirname);
                        }
                    }
                }
            }
        }
    }
    public static IEnumerable <FileSystemInfo> SafeEnumerateFileSystemInfos(this DirectoryInfo di, string filePattern, string dirPattern, SearchOption searchOpt = SearchOption.TopDirectoryOnly, ReturnOptions returnOpt = ReturnOptions.ReturnBoth)
    {
        var searchQueue = new Queue <DirectoryInfo>();

        searchQueue.Enqueue(di);
        while (searchQueue.Count > 0)
        {
            var cdi = searchQueue.Dequeue();

            IEnumerable <string> cdiFiles = null;
            if (returnOpt.HasFlag(ReturnOptions.ReturnFiles))
            {
                try {
                    cdiFiles = Directory.EnumerateFiles(cdi.FullName, filePattern, SearchOption.TopDirectoryOnly);
                }
                catch (Exception) {
                }

                if (cdiFiles != null)
                {
                    var cfis = new ConcurrentBag <FileInfo>();
                    cdiFiles.AsParallel()
                    .ForAll(f => {
                        try {
                            cfis.Add(new FileInfo(f));
                        }
                        catch (Exception) {
                        }
                    });

                    foreach (var fi in cfis)
                    {
                        yield return(fi);
                    }
                }
            }

            if ((!returnOpt.HasFlag(ReturnOptions.ReturnFiles) || cdiFiles != null) && (returnOpt.HasFlag(ReturnOptions.ReturnDirectories) || searchOpt.HasFlag(SearchOption.AllDirectories)))       // skip if file enumeration failed
            {
                IEnumerable <string> cdiDirs = null;
                try {
                    cdiDirs = Directory.EnumerateDirectories(cdi.FullName, dirPattern, SearchOption.TopDirectoryOnly);
                }
                catch (Exception) {
                }

                if (cdiDirs != null)
                {
                    var cdis = new ConcurrentBag <DirectoryInfo>();
                    cdiDirs.AsParallel()
                    .ForAll(d => {
                        try {
                            cdis.Add(new DirectoryInfo(d));
                        }
                        catch (Exception) {
                        }
                    });
                    foreach (var rdi in cdis)
                    {
                        if (returnOpt.HasFlag(ReturnOptions.ReturnDirectories))
                        {
                            yield return(rdi);
                        }
                        if (searchOpt == SearchOption.AllDirectories)
                        {
                            searchQueue.Enqueue(rdi);
                        }
                    }
                }
            }
        }
    }
 public static IEnumerable <FileSystemInfo> SafeEnumerateFileSystemInfos(this DirectoryInfo di, string searchPattern, SearchOption searchOpt = SearchOption.TopDirectoryOnly, ReturnOptions returnOpt = ReturnOptions.ReturnBoth) =>
 di.SafeEnumerateFileSystemInfos(searchPattern, searchPattern, searchOpt, returnOpt);
 public static IEnumerable <FileSystemInfo> SafeEnumerateFileSystemInfos(this string path, string filePattern, string dirPattern, SearchOption searchOpt = SearchOption.TopDirectoryOnly, ReturnOptions returnOpt = ReturnOptions.ReturnBoth) =>
 new DirectoryInfo(path).SafeEnumerateFileSystemInfos(filePattern, dirPattern, searchOpt, returnOpt);
Exemplo n.º 16
0
    /// <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);
    }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
    /// <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);
    }