マイクロソフト エバンジェリストのブログ

日本マイクロソフトのエバンジェリストが、技術情報を発信するブログです!

Windows ストア アプリのビルド ターゲットについて

エバンジェリストの荒井です。
今回は、Visual Studio を使っている時にビルド時に利用する構成マネージャを解説します。最初に、言語としてC#、VB、JavaScriptを使用しているプロジェクトの構成マネージャは以下のようになっています。

f:id:ms_eva:20131112093847p:plain

ターゲットとなるプラットフォームには、Any(デフォルト)、x64、x86、ARMがあります。Anyにすると作成されるバイナリー(PEファイル)のヘッダー情報には、x86(0x14C)が書き込まれることで32ビットの実行バイナリーを示すようになります。

たとえば、BingMap SDKやSQLiteなどを使用する場合は、Anyではなく、x64、x86、ARMなどとターゲットとするCPUアーキテクチャを明示的に指定する必要があります。この理由は、BingMap SDKやSQLiteが VC++のランタイム ライブリーに依存しているからです。VC++ランタイム ライブラリーは、ターゲットCPUごとのネイティブコードを含んでいることから、Any(デフォルト)のターゲット プラットフォームを使用できなくなります。HTML/JavaScriptのストア アプリの場合は、コード自体はバイナリーではありませんが、依存するライブラリーに応じてターゲット プラットフォームを変更する必要があります。一方で、HTML/JavaScriptのストア アプリをインストールすると、JavaScriptコードがプリコンパイルされます。プリコンパイルすることで、実行時の速度がC#やVBと遜色がないようになります。

今度は、C++で作成するストア アプリのプロジェクトの構成マネージャを以下に示します。

f:id:ms_eva:20131112093822p:plain

C++/CXのターゲット プラットフォームは、Win32(デフォルト)、x64、ARMがあります。Win32が、x86のネイティブコードを出力することになります。C#やVBなどと違って、Anyが存在しないのがC++の特徴になっています。Anyという設定は、CPUアーキテクチャ非依存の開発環境だけの特別な設定になるわけです。つまり、C#とVBが出力するコードは、CPU非依存の中間言語(MSIL)であり、HTML/JavaScriptは単なるテキストなのでCPU非依存となるわけです。一方で、C++コンパイラーは、CPU依存のネイティブコードを出力するという理由から、ターゲットプラットフォームにこのような違いが存在するのです。

ストアへ提出するパッケージ

ストアへ提出する場合は、パッケージ(appxファイル)を作成する必要がありますが、この時にターゲット プラットフォームを注意する必要があります。

f:id:ms_eva:20131112100105p:plain

Neutralは、C#やVB、HTML/JavaScriptのアプリでVC++ランタイムに依存しない場合に選択することができます。Neutralで作成したパッケージは、x86/x64/ARMのプラットフォームで動作させることができます。

一方で、VC++ランタイムに依存していたり、VC++で開発したアプリの場合は、Neutralのチェックを取り、目的とするアーキテクチャに対してチェックを付けます。たとえば、x86/x64/ARMで動作させたい場合はx86/x64/ARMにチェックを付けます。

Windows 8.1向けに拡張された機能として、アプリケーション バンドルがあります。アプリケーション バンドルを使用しない場合は、同じバージョン番号で目的のアーキテクチャごとのパッケージを作成します。つまり、x86/x64/ARMという3種類のパッケージで、ストアに申請するときに3種類のパッケージをアップロードします。

アプリケーション バンドルを使用すると、x86/x64/ARMにチェックを付けても1つのアプリケーション バンドルを作成するようになります。作成されたアプリケーション バンドルの中にx86/x64/ARMのパッケージが含まれている構造となります。アプリケーション バンドルの本来の目的は、アプリケーションコードとリソースファイルの分離にあります。たとえば、複数の言語に対応するためのリソースであったり、ゲームコンテンツ向けのリソースなどが、アプリケーションコード以上に容量を必要とすることが良くありますから、このような時に容易にリソースを入れ替えできるようにするというのが、アプリケーション バンドルの目的なのです。

作成されるアプリ パッケージに応じて、適切にCPUアーキテクチャやアプリ パッケージなのか、アプリケーション バンドルなのかを選択するようにしてください。

Unity 4.3 がリリースされました。Windows ストアアプリ向けの改良にご注目!!

f:id:ms_eva:20131113172337p:plain

エバンジェリスト 大西です。
Unity 4.3がリリースされました。拍手 (^-^)/8888
公式のリリースノートは、次の URL にあります。

What's New - Unity 4.3
http://unity3d.com/unity/whats-new/unity-4.3

結構たくさんあるので、Windows ストアアプリに関するところだけを抜き出してみました。Windows 8.1への対応、UnityScript (JS) / Boo のサポートが特にうれしいですね。Unity 4.2でWindows ストアアプリへの対応を見送ったみなさん、これからがチャンスですよ。

 

Features
•Implemented Screen.lockCursor API in Windows Store Apps
•Windows Store Apps: added API to get application activation arguments sent by secondary tile, toast notification now can send activation arguments.
•Windows Store Apps: implemented API to update tiles and show notifications
•Windows Store Apps: support for UnityScript / Boo

Changes
•Windows Phone 8/+ Windows Store Apps: Transferred Trial API from UnityEngine.Application to UnityEngine.Windows.LicenseInformation class.

Improvements
•Windows Phone/+ Windows Store Apps: Exposed application trial API.
•Windows Store Apps: background color override support in extended splash screen on Windows 8.1
•Windows Store Apps: Support rendering in non-native resolutions on Metro 8.1
•Windows Store Apps - Windows 8.1: Input callbacks will now be processed on application thread instead of UI thread, thus reducing input lag.
•Windows Store Apps - Windows 8.1: Will use Direct3D low-latency presentation API http://msdn.microsoft.com/en-us/library/windows/apps/bg182880.aspx#five, this should improve input latency.
•Windows Store Apps & + Windows Phone: Windows 8 requirement to build for Windows Phone/Windows Store Apps is always listed in build settings if it isn't met.
•Windows Store Apps: Added Master configuration to the exported solution, so now there will be three - Debug, Release, Master like on Windows Phone 8. Master configuration should be used when releasing the game. Release configuration is the same as Master, but has Profiler enabled, that's the only difference.
•Windows Store Apps: Animator.GetCurrentAnimationClipState, Animator.GetNextAnimationClipState should work now.
•Windows Store Apps: Added UnityEngine.WSA.Application.windowsActivated event, which can be used for capturing events when snapping begins and ends.
•Windows Store Apps: Implemented Screen.sleepTimeout
•Windows Store Apps: Fixed some of the issues with external plugins, for ex., Facebook.dll, EasyRoads3D.dll
•Windows Store Apps: Windows 8.1 support.
•Windows Store Apps: Cloth is supported now.
•Windows Store Apps: Editor will check if plugins used by Editor and Windows Store Apps are compatible, for ex., it will check if assembly version matches.
•Windows Store Apps: Editor will perform a check if user is running under Windows 8 or higher, if not Build buttons will be disabled.
•Windows Store Apps: Unity splash screen will be shown if user doesn't have a Pro license.
•Windows Store Apps: Added UnityEngine.WSA.Application.windowSizeChanged event, which will be invoked when user resizes the window, for ex., when performing snaping.
•Windows Store Apps: Implemented LocationService and Compass.
•Windows Store Apps: Compilation Overrides will only affect C# files not located in "Standard Assets", "Pro Standard Assets" or "Plugins" folders.
•Windows Store Apps: Managed-To-Native functions now use Platform Invoke to perform interop, performance should be better now.
•Windows Store Apps: New APIs. UnityEngine.Windows.File, UnityEngine.Windows.Directory for accessing directories and files. UnityEngine.WSA.Application for invoking calls on different threads.
•Windows Store Apps: Resources.UnloadUnusedAssets should work correctly now.
•Windows Store Apps: When generating C+/C# solution, Mixed Mode debugging will be enabled by default.
•Windows Store Apps: Make sure gui password field is drawing mask char, even though os keyboard returns clear text.

Fixes
•Fix error messages in Windows Store Apps and WP8 when checking for location capability
•Fix errors when snapping on Windows Store Apps
•Fix F10 and Shift keys in Windows Store Apps
•Windows Phone/+ Windows Store Apps: Fixed unity player crashing if fields in user scripts were emitted with #if UNITY_EDITOR precessor flag.
•Windows Phone/+ Windows Store Apps: Reference ReWriter will now correctly find replacement method with param arguments if original is not available in the target framework.
•Windows Store Apps: fixed GUI events via touches when cursor is locked
•Windows Store Apps: fixed LocationService DesiredAccuracy usage on Windows 8.1
•Windows Store Apps: Fixed out of bounds error while batching 2D sprites.
•Windows Store Apps: fixed parameter marshaling of type 'char' in UnityEngine API, this fixes following Unity functions - Event.character, Font::HasCharacter, Font::GetCharacterInfo. Because of this bug chinese, russian texts in some cases were being displayed incorrectly.
•Windows Store Apps: fixed starting coroutines with arguments of wrong but compatible tipe
•Windows Store Apps: PlayerPrefs will be loaded before calling OnEnable function.
•Windows Store Apps: fix crash in mesh
•Windows Store Apps: fix freeze on Windows 8.1 when waiting for input
•Windows Store Apps: Screen.orientation will work correctly (was fixed in 4.3 a1).
•Windows Store Apps / Windows 8.1: Fixed regression from 4.3 b3, any touch or mouse input won't longer hang the application.
•Windows Store Apps / Windows 8.1: IDXGIDevice3::Trim will be called on application suspend event, WACK requirement.
•Windows Store Apps: fix cursor move when Screen.showCursor is set to false
•Windows Store Apps: Fix AssemblyResolutionException during game postprocess when code references members from Windows namespace.
•Windows Store Apps: Show "Not applicable" for icon in player settings
•Windows Store Apps: Allow to unfold and show "Not applicable" for splash in player settings
•Windows Store Apps & + Windows Phone: Fixed constructor injection, improved error reporting
•Windows Store App/+ Windows Phone: String with unicode symbols (for ex., Chinese) will be correctly serialized.
•Windows Store Apps: WWW will correctly load files via file:/// protocol, and won't require internet capability to be enabled.
•Windows Store Apps: C# files located in Plugins, Standard Assets or Pro Standard Assets won't be compiled against .NET Core even if player setting are set to compile against .NET Core. This way js/boo will be able to access classes from C# files, C# files in other locations can be compiled against .NET Core depending on Player Settings.
•Windows Store Apps: RequireComponent works now.
•WSA / WP8: Better error message when UnityScript code calls Eva() function on platforms that don't support it

以上です。