【发布时间】:2021-09-28 12:03:24
【问题描述】:
我想在unity的通用windows平台开发中使用windows runtime API。
我参考this site做了如下脚本。
#define ENABLE_WINMD_SUPPORT
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour
{
void Start()
{
#if ENABLE_WINMD_SUPPORT
Debug.Log(Windows.System.UserProfile.AdvertisingManager.AdvertisingId);
#endif
}
}
但是,我收到这样的错误并且它不起作用。
“错误 CS0103:名称 'Windows' 在当前上下文中不存在”
如果有人知道解决方案,请告诉我。
我尝试了什么
·在播放器设置(编辑>项目设置>播放器)中将API兼容级别设置为.NET Standard 2.0
·将目标平台改为通用windows平台
・使用 Unity 2021.1.15、2020.3.14f1、2018.4.36f1 尝试上述操作。
参考网站 https://docs.unity3d.com/ja/2021.1/Manual/IL2CPP-WindowsRuntimeSupport.html https://docs.unity3d.com/2021.1/Documentation/Manual/windowsstore-scripts.html
【问题讨论】:
-
“这样的错误”,这样的错误是什么?错误的详细信息是什么?
-
感谢您的回复。错误看起来像这样。错误 CS0103:当前上下文中不存在名称“Windows”
-
你查过这个错误是什么意思吗?你了解 C# 是如何解析引用的吗?
标签: c# unity3d winapi uwp windows-runtime