【发布时间】:2020-03-23 16:58:13
【问题描述】:
在我的场景中,按钮是在运行时创建的。这些将通过语音命令单击。出于这个原因,我试图找出如何在运行时添加语音命令。但我找不到任何方法。
我尝试了什么:
我用两种方法扩展了接口IMixedRealitySpeechSystem,RefreshRecognition 和AddSpeechCommand:
/// <summary>
/// Refresh recognition after adding new commands
/// </summary>
void RefreshRecognition();
/// <summary>
/// Add command to already existing commands[]
/// </summary>
/// <param name="command"></param>
void AddSpeechCommand(SpeechCommands command);
我已经在WindowsSpeechInputProvider: MixedRealitySpeechSystem 类中实现了这些。但是有两个问题。
首先:我无法访问 WindowsSpeechInputProvider。我想我可以试试这个:
private IMixedRealitySpeechSystem SpeechSystem
{
get
{
if(_speechSystem is null)
{
MixedRealityServiceRegistry.TryGetService(out _speechSystem);
}
return _speechSystem;
}
}
public void SomeMethod()
{
SpeechCommands command = new SpeechCommands("TestCommand", default, default, null);
SpeechSystem.AddSpeechCommand(command);
SpeechSystem.RefreshRecognition();
}
但问题是MixedRealityServiceRegistry 不包含该服务的实例,或者准确地说,它甚至不是服务。
第二:即使这样可行,也不是一个好方法。因为这样我更改了 MRTK 并再次升级到新版本,所以这些行被覆盖了。
我的问题:
那么如何在运行时访问和添加命令呢?
【问题讨论】:
标签: unity3d augmented-reality hololens mrtk