Пример #1
0
 public static void WaapiClientTest2()
 {
     if (AkWaapiClient.Connect("127.0.0.1", 8080))
     {
         Debug.Log("Connect Success!");
         string WaapiResult = string.Empty;
         bool   res         = AkWaapiClient.Call("ak.wwise.core.remote.disconnect", "{}", "{}", out WaapiResult);
         if (res)
         {
             var projectInfo = ProjectInfo.Create(WaapiResult);
             Debug.LogWarning(projectInfo);
         }
         else
         {
             Debug.Log("Call failed :(");
         }
         var Options = new CallOptions {
             @return = new[] { "id" }
         };
         ulong subId = 0;
         res = AkWaapiClient.Subscribe("ak.wwise.core.object.created", Options, OnObjectCreated, out subId, out WaapiResult);
         if (res)
         {
             Debug.Log("Subscribe success!" + WaapiResult);
         }
         else
         {
             Debug.Log("Subscribe failed :(");
         }
     }
     else
     {
         Debug.Log("Connect fail :(");
     }
 }
Пример #2
0
    /// <summary>
    /// Checks the global WAAPI settings and disconnects if WAAPI is disabled or connection settings have changed.
    /// If disconnected, try to connect with current settings.
    /// </summary>
    /// <returns>True if the client is connected</returns>
    private static async Task <bool> CheckConnection()
    {
        if (AkWwiseEditorSettings.Instance.UseWaapi)
        {
            // If WAAPI connection settings have changed, unsubcribe and close the connection.
            if (ConnectionSettingsChanged() && WaapiClient.IsConnected())
            {
                FireDisconnect(false);
                return(true);
            }

            if (!WaapiClient.IsConnected())
            {
                try
                {
                    await m_WaapiClient.Connect(GetUri());
                }
                catch (System.Exception)
                {
                    ConnectionFailed("Connection refused");
                }
            }

            if (WaapiClient.IsConnected())
            {
                var projectOpen = await CheckProjectLoaded();

                if (!projectConnected && projectOpen)
                {
                    projectConnected = true;
                    loopSleep        = 0;
                    Connected?.Invoke();
                }
                else if (projectConnected && !projectOpen)
                {
                    FireDisconnect(false);
                    return(true);
                }
            }
        }

        else
        {
            if (WaapiClient.IsConnected() && !isDisconnecting)
            {
                FireDisconnect(false);
                return(true);
            }
        }

        return(WaapiClient.IsConnected() && projectConnected);
    }
Пример #3
0
    public static void WaapiClientTest()
    {
        if (AkWaapiClient.Connect("127.0.0.1", 8080))
        {
            Debug.Log("Connect Success!");
            string WaapiResult = string.Empty;

            MyArgument myArgument = new MyArgument();
            myArgument.host = "127.0.0.1";
            string json = JsonUtility.ToJson(myArgument);

            bool res = AkWaapiClient.Call("ak.wwise.core.remote.connect", json, "{}", out WaapiResult);
            //connect wwise from menu
            //https://docs.unity3d.com/Manual/JSONSerialization.html

            if (res)
            {
                var projectInfo = ProjectInfo.Create(WaapiResult);
                Debug.LogWarning(projectInfo);
            }
            else
            {
                Debug.Log("Call failed :(");
            }
            var Options = new CallOptions {
                @return = new[] { "id" }
            };
            ulong subId = 0;
            res = AkWaapiClient.Subscribe("ak.wwise.core.object.created", Options, OnObjectCreated, out subId, out WaapiResult);
            if (res)
            {
                Debug.Log("Subscribe success!" + WaapiResult);
            }
            else
            {
                Debug.Log("Subscribe failed :(");
            }
        }
        else
        {
            Debug.Log("Connect fail :(");
        }
    }