gpt4 book ai didi

c# - 在 Unity UWP 应用程序中找不到命名空间 'Windows'

转载 作者:行者123 更新时间:2023-12-04 16:52:08 26 4
gpt4 key购买 nike

我正在尝试在 Unity 中设置一个基本的 UWP 项目并使用部分 Windows 命名空间。*但是,无论我尝试在我的脚本中导入 Windows namespace 的哪一部分,我总是得到

CS0246: The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)

在 Visual Studio 和 Unity 中设置了对 Windows 和 UWP 的构建支持,并安装了 Windows 10 SDK (10.0.19041.0)。还有其他解决方法吗?

基于 https://forum.unity.com/threads/windows-storage-is-missing-when-building-for-uwp-hololens.541415/我会假设 Windows 在 UWP 的 Unity 中可用,因为他们能够在那里修复它?

谢谢


*从长远来看,我正在尝试使用“Windows.Devices.Input.Preview”在一个也使用 Vuforia 的项目中访问 Gaze Input,因此需要 UWP。也欢迎提供有关如何在 Unity 中结合注视跟踪和标记识别的其他技巧。

最佳答案

Unity 中的 Windows 命名空间仅适用于 Windows PC 构建。它不适用于其他系统。在脚本的顶部尝试添加一个

#if UNITY_STANDALONE_WIN

你应该像这样添加整个声明

#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
Use SpeechRecognitionEngine class

#endif

如果您正在为 android 或 ios 构建您还需要添加:

 #if UNITY_ANDROID  
Use SpeechRecognizer class

#endif

#if UNITY_IOS使用 SFSpeechRecognizer 类#endif

关于c# - 在 Unity UWP 应用程序中找不到命名空间 'Windows',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65117814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com