LoginSignup
30
17

More than 3 years have passed since last update.

Unityでスマホアプリ(特にプラグイン)を開発している人のための2016年対応まとめ

Last updated at Posted at 2016-12-07

個人的なことですが6月にUnityでのゲーム開発からUnityのスマホ向けプラグイン開発にジョブチェンジしました。
プラグイン開発では、ゲーム開発者が使用しているUnityのバージョンや開発環境を
広くサポートしないといけないのでUnityバージョンの仕様の違いやiOS,Androidの最新事情について敏感になりました。

なのでUnityを使ったスマホアプリ開発について、
個人的に確認や対応が必要となった2016年のニュースを時系列でざっくりまとめてみました。

Unityしばらく触ってない人もこの記事を見れば今年のいろいろが分かる(かも)

2016年5月 Google Google/IOでFirebaseリニューアルを発表

Firebaseとか使わないし関係ないし!..と思う人もいると思いますが!
ざっくりいうとGoogle Play Service9.0対応です。

簡単な歴史を説明するとGoogle Play Serviceは広告SDKなどに必須の
「広告IDを取得する機能」などが含まれておりGoogle Play Service6.5未満はgoogle-play-services.jarを追加する必要がありました。

ただし上の方法だとGoogle Play Service全ての機能が追加されるため、メソッド数が65Kを超えAndroidでビルドできないケースがありました。
そこでGoogle Play Service6.5以降はモジュール単位の追加が可能に。
GoogleからUnityでモジュール単位で追加するためのPlayServiceResolverというものが公開されました。
https://github.com/googlesamples/unity-jar-resolver
(ちなみにこの機能はaarライブラリで追加するためjarしか使用できないUnity4系では使用できません)

そんなGoogle Play Serviceですが2016年5月にリリースされた9.0では一部の機能がFirebaseに移行されたためパッケージ名の一部が異なっています。
AppInvitesはFirebase Invites, GCMはFirebase Messagingなどに変わっています。

8.x 9.x
com.google.android.gms.appinvite com.google.firebase:firebase-invites
com.google.android.gms.gcm com.google.firebase:firebase-messaging
com.google.android.gms.measurement com.google.firebase:firebase-core

ちなみにGoogle Play ServiceとFirebaseは2017年からAndroid14(4.0)以上のサポートとなるようです。これが理由で今後Android2系Android3系のサポートはぐっと減ると思われます。
参考) https://googledevjp.blogspot.jp/2016/12/google-play-services-and-firebase-for-android-will-support-api-level-14-at-minimum.html

2016年6月 Apple 2016年6月1日から全てのiOSでIPv6サポートを義務化

Appleが義務化ということは破ったら審査が通らなくなるよということで必須の対応です。
こちらは5月10日にUnityが旧バージョン含むサポートを告知しました。
https://blogs.unity3d.com/jp/2016/05/10/unity-and-ipv6-support/

2016年7月 Unity5.4リリース!

https://blogs.unity3d.com/jp/2016/07/28/unity-5-4-is-out-heres-whats-in-it/
https://unity3d.com/jp/unity/whats-new/unity-5.4.0
夏真っ盛りのときにUnity5.4リリース。
シネマティックイメージエフェクトやらVR対応やら。
そんな中モバイル系で確認や対応が必要な変更は主に以下だと思います。

  • IL2CPP: IL2CPPのAndroid用サポート
  • iOS: 最小サポートバージョンを 7.0 へ更新
  • Android: UnityPlayerNativeActivity と UnityPlayerProxyActivity が非推奨に。

上のUnityPlayerNativeActivity, UnityPlayerProxyActivityについて説明します。

まず空のUnityプロジェクトをAndroid向けにexportするとソースファイルは以下の3つになります。
AndroidManifestとソースコードを見ると、以下のどれかのActivity上でUnityアプリが動作していることがわかります。

スクリーンショット 2016-12-07 2.18.04.png

UnityPlayerActivityとUnityPlayerNativeActivityの主な違いは継承しているのがActivityかNativeActivityかです。UnityPlayerProxyActivityはその名の通りProxyの役割をしていて、条件によってどちらかを起動させています。(以下、コード抜粋)

UnityPlayerActivity.java@Unity5.3
public class UnityPlayerActivity extends Activity
{
    protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
:
UnityPlayerNativeActivity.java@Unity5.3
public class UnityPlayerNativeActivity extends NativeActivity
{
    protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
:
UnityPlayerProxyActivity.java@Unity4.7
/**
 * @deprecated Use UnityPlayerNativeActivity instead.
 */
public class UnityPlayerProxyActivity extends Activity
{
    protected void onCreate (Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, my.project.UnityPlayerNativeActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        Bundle extras = getIntent().getExtras();
        if (extras != null)
            intent.putExtras(extras);
        startActivity(intent);
    }
}

UnityPlayerProxyActivity.java@Unity5.3
/**
 * @deprecated Use UnityPlayerActivity instead.
 */
public class UnityPlayerProxyActivity extends Activity
{
    protected void onCreate (Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, my.project.UnityPlayerActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        Bundle extras = getIntent().getExtras();
        if (extras != null)
            intent.putExtras(extras);
        startActivity(intent);
    }
}

Unity4.xではUnityPlayerNativeActivityをデフォルトに、Unity5.xではUnityPlayerActivityをデフォルトに動作させています。
Unity5.4からUnityPlayerNativeActivityは空クラスとなり動作しなくなりました。
Native連携のプラグインなどを導入している場合、AndroidManifestのActivity呼び出し箇所にUnityPlayerNativeActivityを使用しているとアプリが落ちます。
プラグイン提供者は使用者のUnityバージョンによってサポートするActivityを切り替えなければいけないのでお気をつけて。
AndroidでProjectをexportして運用しているチームもUnity5.4に上げる際は上記気をつけてください。

2016年8月 Android7.0リリース!

Androidは厳しい審査が無く、普及も緩やかなので悲鳴はないですが
Android7.0では安全性, セキュリティ面の向上を推進している印象です。
将来的にiOSのATSのように必須になったときのために、以下セキュリティ周りの記事は読んでおいて損はないと思います。

2016年9月 iOS10リリース!

iOS9でATS対応に追われたのが2015年のことでした。
その時ほどではありませんが、今回もいろいろな罠があるので一部を紹介します。

iOS10でATSの仕様変わった問題

ATSの適応で、NSAllowsArbitraryLoadsInWebContentなど一部追加,変更がありました。対応の際には、はてな開発者ブログ様の以下記事を参考にさせていただきました。
http://developer.hatenastaff.com/entry/2016/06/16/165924

XCode8にすると古いApplication Loader使えない問題

スクリーンショット 2016-12-02 1.34.07.png
iOSアプリ開発者で、アプリを審査提出する際にApplication Loaderを使用している方は多いと思います。XCode8では上の画像から起動できる最新版を使用しないと提出時にエラーを吐くようです。
Application Loader3.0でエラーを確認しました。

XCode8にしてアプリを提出するとNS*UsageDescriptionに関するメールくる問題

スクリーンショット 2016-12-02 1.46.39.png
XCode8でビルドする場合、上記のようにカメラやカレンダーなど一部の機能を使う際にInfo.plistにPrivacyの記述がないと審査時にリジェクトされます。審査提出後に発覚する問題なのでこちら要注意です。

2016年12月 Unity5.5リリース!

https://blogs.unity3d.com/jp/2016/11/29/unity-5-5-is-ready-for-you/
https://unity3d.com/jp/unity/whats-new/unity-5.5.0

5.4から5.5の間隔が短い!
個人的にUnity5.4からUnity5.5の移行がスムーズに済んでしまったのと
調査不足のため注意点など挙げられません。
しいて言うならUnity5.5からAndroidのビルドシステムの項目ができてGradleが指定できるようになりました。こちらでAndroid ProjectをexportするときちんとAndroid Studioのフォルダ構成で出力されるようになりました。(これまではeclipse向けのフォルダ構成でした)

スクリーンショット 2016-12-07 2.11.45.png

感想

スマホのプラグイン開発目線でざっくりまとめましたが振り返るとUnityやモバイルのバージョンアップは速い..!
そしてiOS対応は対応が多く毎度何かが削られる気がします。
去年まではUnityやってたけど今年は他の仕事やってた的な人がこの記事で浦島状態になるのを避けられれば本望です。

来年はきっとATS本対応で慌てそうなので今年の対応は今年のうちにぜひ。

おわり

30
17
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
17