Unity3d Windows 10通用语音命令命令前缀

Unity3d Windows 10通用语音命令命令前缀,unity3d,win-universal-app,windows-10-universal,voice-recognition,cortana,Unity3d,Win Universal App,Windows 10 Universal,Voice Recognition,Cortana,您好,我有一个关于在Windows10UA中使用语音命令的问题。我已经在Unity3D创建的通用应用程序中添加了一个语音命令定义文件,并添加了必要的代码,以便在第一次运行时进行安装。但是,当第一次启动时,它从不响应语音命令。我添加了一个命令前缀,它应该允许有人通过说出该前缀来启动应用程序,但当我这样做时,它只会打开Cortana搜索 我不知道为什么会这样 以下是代码的重要部分: Xml: 激活时: protected override void OnActivated(IActivatedEve

您好,我有一个关于在Windows10UA中使用语音命令的问题。我已经在Unity3D创建的通用应用程序中添加了一个语音命令定义文件,并添加了必要的代码,以便在第一次运行时进行安装。但是,当第一次启动时,它从不响应语音命令。我添加了一个命令前缀,它应该允许有人通过说出该前缀来启动应用程序,但当我这样做时,它只会打开Cortana搜索

我不知道为什么会这样

以下是代码的重要部分:

Xml:

激活时:

protected override void OnActivated(IActivatedEventArgs args)
        {
            string appArgs = "";

            switch (args.Kind)
            {
                case ActivationKind.Protocol:
                    ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
                    splashScreen = eventArgs.SplashScreen;
                    appArgs += string.Format("Uri={0}", eventArgs.Uri.AbsoluteUri);
                    break;
                case ActivationKind.VoiceCommand:
                    SpeechHelper.HandleSpeechCommand(args);
                    break;
            }
            InitializeUnity(appArgs);
        }

我已经在附加了调试器的情况下运行了代码,但它从未命中OnActivated(..)方法。

与Cortana的集成意味着您需要首先调用Cortana UI,然后从那里运行命令。您可以询问cortana内部要运行哪些命令,如中的详细说明所述。这是你想要通过的步骤吗,即在没有Cortana UI的情况下运行命令?你是否尝试过在Cortana中输入文本“Unity Battle”?
protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            try
            {
                Windows.Storage.StorageFile vcdStorageFile =
                    await Package.Current.InstalledLocation.GetFileAsync(@"VoiceCommandDefinition.xml");

                await
                    Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager
                        .InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }
}
protected override void OnActivated(IActivatedEventArgs args)
        {
            string appArgs = "";

            switch (args.Kind)
            {
                case ActivationKind.Protocol:
                    ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
                    splashScreen = eventArgs.SplashScreen;
                    appArgs += string.Format("Uri={0}", eventArgs.Uri.AbsoluteUri);
                    break;
                case ActivationKind.VoiceCommand:
                    SpeechHelper.HandleSpeechCommand(args);
                    break;
            }
            InitializeUnity(appArgs);
        }