Version: 2017.2
AppCallbacks 클래스
유니버설 Windows 플랫폼 플레이어 설정(Universal Windows Platform Player Settings)

유니버설 Windows 플랫폼: C# 스크립트의 WinRT API

Unity 스크립트에서 직접 WinRT API를 사용할 수 있습니다만, 아래의 제약과 요구 사항이 따릅니다.

  • 스크립트는 C#로 작성되어야 하고 UnityScript에서 WinRT API를 사용할 수는 없습니다.
  • 스크립트는 Mono가 아닌 Microsoft 컴파일러를 사용하여 컴파일되어야 합니다. 따라서 컴파일 오버라이드를 Use .NET Core이나 Use .NET Core Partially로 설정해야 합니다. 후자의 경우 스크립트는 Plugins 또는 Standard Assets 폴더에 있어서는 안됩니다.
  • 항상 Mono를 사용하는 Unity 에디터가 동일한 스크립트 코드를 사용하므로, WinRT API를 사용하는 모든 코드는 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
    }
}

참고: IL2CPP 스크립팅 백엔드를 사용하는 경우 이 기능은 .NET 4.6 호환성 프로파일을 사용하는 경우에만 지원됩니다.

AppCallbacks 클래스
유니버설 Windows 플랫폼 플레이어 설정(Universal Windows Platform Player Settings)