UWP용 C# 스크립트의 WinRT API
Use WinRT API directly in Unity scripts for UWP.
읽는 시간 1분최근 업데이트: 한 달 전
Windows 런타임 지원이 활성화된 경우 Unity 스크립트에서 직접 WinRT API를 사용할 수 있습니다. WinRT API를 사용하고 Windows 런타임 지원을 활성화하는 방법에 대한 자세한 내용은 Windows 런타임 지원을 참조하십시오.
Unity 스크립트에서 WinRT API를 사용하려면 다음 요구 사항을 충족해야 합니다.
- 스크립트는 C#으로 작성해야 합니다.
- API 호환성 레벨은 플레이어 설정에서 .NET 4.6 또는 .NET Standard 2.0으로 설정해야 합니다.
- WinRT API를 사용하는 모든 코드는 지시문에 따라야 합니다. 이는 에디터가 WinRT API를 지원하지 않는 Mono를 사용하기 때문에 필요합니다.
ENABLE_WINMD_SUPPORT
다음 코드 예시에서는 WinRT API를 사용하여 직접 광고를 가져오는 방법을 보여 줍니다.
using UnityEngine;public class WinRTAPI : MonoBehaviour{ void Update() { auto adId = GetAdvertisingId(); // ... } string GetAdvertisingId() { #if ENABLE_WINMD_SUPPORT return Windows.System.UserProfile.AdvertisingManager.AdvertisingId; #else return ""; #endif }}