LoginSignup
11
13

More than 5 years have passed since last update.

Unity5でwebViewを表示する

Last updated at Posted at 2015-07-27

Unity5でwebViewを表示させようとしてハマったので、メモ。
iosシミュレータで表示させるまでやりました。
androidは未確認です。

gree社製プラグイン

コチラから落としてきます。

Unity5ではエラーが出る

Runしようとすると下記エラーが出るので対応します。

"Couldn't open Assets/Plugins/WebView.bundle/Contents/MacOS/WebView, error: dlopen(Assets/Plugins/WebView.bundle/Contents/MacOS/WebView, 2): no suitable image found. Did find:
Assets/Plugins/WebView.bundle/Contents/MacOS/WebView: mach-o, but wrong architecture"

こちらのやり方で解決しました。
プラグインのWebView.bundleというファイルを生成し直します。

  • plugins/Mac/WebView.xcodeproj をひらく
  • Build Setting -> 「Architectures」 -> 「Architectures」を64bit architectureに変更する

スクリーンショット 2015-07-27 0.56.20.png

  • 「Product」 -> 「Archive」からWebView.bundleを生成する

スクリーンショット 2015-07-27 0.56.33.png

  • XCodeのOrganizerが立ち上がるので、「Export」からファイルを書き出します
  • それを"Plugins/WebView.bundle"に上書きます

ソースコード

こちらのコードを拝借させていただきました。

iosビルドするとXCodeでエラーが出る

'retain' is unavailable: not available in automatic reference counting mode

arc周りでエラーがでてるっぽいです。
こちらのやり方で解決しました。
Build PhasesのCompileSourcesでWebView.mmのCompiler Flagsに"-fno-objc-arc"を追加
スクリーンショット 2015-07-27 11.08.38.png

この方法だと、Unity上ではwebviewは見れないです。
ビルドして実機orシミュレーターで確認するしかなさそうです。

  • シミュレーターで確認

スクリーンショット 2015-07-27 11.16.45.png

11
13
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
11
13