LoginSignup
2
4

More than 5 years have passed since last update.

UnityのLow level Native Plugin interfaceをAndroidで動かす

Posted at

前置き

Unity 5.3ではAndroid/iOSのLow level native plugin interfaceが動かない.
Unity 5.4 beta からOpenGLESもサポートされ正常に動くようになった。
いろいろハマったのでその時のセットアップメモ。

手順

1. Unity 5.4 betaをdownload

5.3だと動かないので注意。 (get
Install するコンポーネントには Example ProjectとAndroid Build SupportとiOS Build Supportを含める

component.png

2. Example Projectを展開する

$ cp /Applications/Unity/Documentation/en/uploads/Examples/RenderingPluginExample54.zip .
$ unzip RenderingPluginExample54.zip

3. Androidのdynamic libraryをビルドする

すでにビルド済みなのでやらなくても可。

$ cd RenderingPlugin/Android
$ ndk-build
$ cp libs/armeabi-v7a/libRenderingPlugin.so ../../UnityProject/Assets/Plugins/Android/libRenderinugin.so

4. UnityでAndroid Projectのビルド

Unityで解答したUnityProjectを開く.
scene.unityをダブルクリックして開く.

File > BuildSettings > Android

  • Add Opened Sceneでシーンを追加
  • PlayerSettings > Other Settings > Bundle Identifier => 適当なpackage nameに変更する
  • Development Buildにチェック
  • buildする

apkのインストール

$ adb install your.apk

結果

small.png

球体の裏で三角形が回転されながら表示されていればOK.
FragmentShaderが上手く動いていると色もグラデーションがかっているはず。

自分でC++のPluginを作るときには、 /Applications/Unity/Unity.app/Contents/PluginAPI/ に IUnityInterface.h などが配置してあるので、それを参照してビルドすればよさそう。

2
4
0

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
2
4