[
  {
    "path": ".gitignore",
    "content": ".DS_Store\n*.swp\nandroid/bin/*\nandroid/gen\nandroid/proguard.cfg\nandroid/local.properties\nunity/Library\nunity/Temp\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "Copyright (C) 2011 Keijiro Takahashi\n\nThis software is provided 'as-is', without any express or implied\nwarranty.  In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n   claim that you wrote the original software. If you use this software\n   in a product, an acknowledgment in the product documentation would be\n   appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\n   misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n"
  },
  {
    "path": "README.md",
    "content": "### 概要\n\nUnity iOS および Android において web view を画面内に組み込み、その内部と連携を行うためのプラグインの実装例です。\n\n![screenshot](https://github.com/downloads/keijiro/unity-webview-integration/IMG_0004.jpg)\n\n上図は実装されたサンプルシーンを実行した様子です。上部が Unity の画面で、下部が web view です。Web view 内のリンクをクリックすることにより Unity 画面内で特定のアクションが発動されます。\n\n### 簡単な解説\n\n#### Unity 側\n\n[Assets/Plugins/WebMediator.js](https://github.com/keijiro/unity-webview-integration/blob/master/unity/Assets/Plugins/WebMediator.js) が Unity 側の窓口となるスクリプトです。このスクリプトを通して web view の表示制御、配置マージン設定、指定 URL のロードを行うことができます。また、web view 内から送信されたメッセージをここから拾い上げることができます。詳しい使用方法についてはサンプルプロジェクトの [TestInterface.js](https://github.com/keijiro/unity-webview-integration/blob/master/unity/Assets/Scripts/TestInterface.js) を参照してください。\n\n#### Web view 側\n\nWeb view 側からメッセージを送信するには [unity.js](https://github.com/keijiro/unity-webview-integration/blob/gh-pages/unity.js) をインポートし、この中で定義されている `UnityWebMediator` クラスを用いる必要があります。詳しい使用方法についてはサンプルプロジェクトの [index.html](https://github.com/keijiro/unity-webview-integration/blob/gh-pages/index.html) を参照してください。\n"
  },
  {
    "path": "android/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      package=\"jp.radiumsoftware.unitywebviewexample\"\n      android:versionCode=\"1\"\n      android:versionName=\"1.0\">\n    <application android:label=\"@string/app_name\" android:icon=\"@drawable/ic_launcher\">\n        <activity android:name=\"ACTIVITY_ENTRY_NAME\"\n                  android:label=\"@string/app_name\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n</manifest>\n"
  },
  {
    "path": "android/ant.properties",
    "content": "# This file is used to override default values used by the Ant build system.\n#\n# This file must be checked in Version Control Systems, as it is\n# integral to the build system of your project.\n\n# This file is only used by the Ant script.\n\n# You can use this to override default values such as\n#  'source.dir' for the location of your java source folder and\n#  'out.dir' for the location of your output folder.\n\n# You can also use it define how the release builds are signed by declaring\n# the following properties:\n#  'key.store' for the location of your keystore and\n#  'key.alias' for the name of the key to use.\n# The password will be asked during the build when you use the 'release' target.\n\n"
  },
  {
    "path": "android/build.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"WebMediator\" default=\"help\">\n\n    <!-- The local.properties file is created and updated by the 'android' tool.\n         It contains the path to the SDK. It should *NOT* be checked into\n         Version Control Systems. -->\n    <loadproperties srcFile=\"local.properties\" />\n\n    <!-- The ant.properties file can be created by you. It is only edited by the\n         'android' tool to add properties to it.\n         This is the place to change some Ant specific build properties.\n         Here are some properties you may want to change/update:\n\n         source.dir\n             The name of the source directory. Default is 'src'.\n         out.dir\n             The name of the output directory. Default is 'bin'.\n\n         For other overridable properties, look at the beginning of the rules\n         files in the SDK, at tools/ant/build.xml\n\n         Properties related to the SDK location or the project target should\n         be updated using the 'android' tool with the 'update' action.\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems.\n\n         -->\n    <property file=\"ant.properties\" />\n\n    <!-- The project.properties file is created and updated by the 'android'\n         tool, as well as ADT.\n\n         This contains project specific properties such as project target, and library\n         dependencies. Lower level build properties are stored in ant.properties\n         (or in .classpath for Eclipse projects).\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems. -->\n    <loadproperties srcFile=\"project.properties\" />\n\n    <!-- quick check on sdk.dir -->\n    <fail\n            message=\"sdk.dir is missing. Make sure to generate local.properties using 'android update project'\"\n            unless=\"sdk.dir\"\n    />\n\n\n<!-- extension targets. Uncomment the ones where you want to do custom work\n     in between standard targets -->\n<!--\n    <target name=\"-pre-build\">\n    </target>\n    <target name=\"-pre-compile\">\n    </target>\n\n    /* This is typically used for code obfuscation.\n       Compiled code location: ${out.classes.absolute.dir}\n       If this is not done in place, override ${out.dex.input.absolute.dir} */\n    <target name=\"-post-compile\">\n    </target>\n-->\n\n    <!-- Import the actual build file.\n\n         To customize existing targets, there are two options:\n         - Customize only one target:\n             - copy/paste the target into this file, *before* the\n               <import> task.\n             - customize it to your needs.\n         - Customize the whole content of build.xml\n             - copy/paste the content of the rules files (minus the top node)\n               into this file, replacing the <import> task.\n             - customize to your needs.\n\n         ***********************\n         ****** IMPORTANT ******\n         ***********************\n         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,\n         in order to avoid having your file be overridden by tools such as \"android update project\"\n    -->\n    <!-- version-tag: 1 -->\n    <import file=\"${sdk.dir}/tools/ant/build.xml\" />\n\n</project>\n"
  },
  {
    "path": "android/project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system use,\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n\nandroid.library=true\n# Project target.\ntarget=android-7\n"
  },
  {
    "path": "android/res/layout/main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\"\n    android:layout_width=\"fill_parent\"\n    android:layout_height=\"fill_parent\"\n    >\n<TextView\n    android:layout_width=\"fill_parent\"\n    android:layout_height=\"wrap_content\"\n    android:text=\"Hello World, ACTIVITY_ENTRY_NAME\"\n    />\n</LinearLayout>\n\n"
  },
  {
    "path": "android/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <string name=\"app_name\">ACTIVITY_ENTRY_NAME</string>\n</resources>\n"
  },
  {
    "path": "android/src/jp/radiumsoftware/unitywebviewexample/ExtendedUnityPlayerActivity.java",
    "content": "// UnityPlayerActivity and WebView integration\n\npackage jp.radiumsoftware.unitywebviewexample;\n\nimport com.unity3d.player.UnityPlayerActivity;\n\nimport android.graphics.Color;\nimport android.os.Bundle;\nimport android.util.Log;\nimport android.view.Gravity;\nimport android.view.View;\nimport android.view.ViewGroup.LayoutParams;\nimport android.webkit.WebChromeClient;\nimport android.webkit.WebSettings;\nimport android.webkit.WebView;\nimport android.webkit.WebViewClient;\nimport android.widget.FrameLayout;\nimport android.widget.ProgressBar;\nimport java.lang.InterruptedException;\nimport java.util.concurrent.SynchronousQueue;\n\npublic class ExtendedUnityPlayerActivity extends UnityPlayerActivity {\n\n    // JavaScript interface class for embedded WebView.\n    private class JSInterface {\n        public SynchronousQueue<String> mMessageQueue;\n\n        JSInterface() {\n            mMessageQueue = new SynchronousQueue<String>();\n        }\n\n        public void pushMessage(String message) {\n            Log.d(\"WebView\", message);\n            try {\n                mMessageQueue.put(message);\n            } catch (java.lang.InterruptedException e) {\n                Log.d(\"WebView\", \"Queueing error - \" + e.getMessage());\n            }\n        }\n    }\n\n    private JSInterface mJSInterface;   // JavaScript interface (message receiver)\n    private WebView mWebView;           // WebView object\n    private ProgressBar mProgress;      // Progress bar\n    private int mLeftMargin;            // Margins around the WebView\n    private int mTopMargin;\n    private int mRightMargin;\n    private int mBottomMargin;\n    private boolean mInitialLoad;       // Initial load flag\n\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        // Create a WebView and make layout.\n        mWebView = new WebView(this);\n        FrameLayout layout = new FrameLayout(this);\n        addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));\n        layout.addView(mWebView, new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.NO_GRAVITY));\n        // Basic settings of WebView.\n        WebSettings webSettings = mWebView.getSettings();\n        webSettings.setSupportZoom(false);\n        webSettings.setJavaScriptEnabled(true);\n        webSettings.setPluginsEnabled(true);\n        //webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);\n        // Set a dummy WebViewClient (which enables loading a new page in own WebView).\n        mWebView.setWebViewClient(new WebViewClient(){});\n        // Add a progress bar.\n        mProgress = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);\n        layout.addView(mProgress, new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, 5));\n        mProgress.setMax(100);\n        mProgress.setVisibility(View.GONE);\n        mWebView.setWebChromeClient(new WebChromeClient() {\n            public void onProgressChanged(WebView view, int progress) {\n                if (progress < 100) {\n                    mProgress.setVisibility(View.VISIBLE);\n                    mProgress.setProgress(progress);\n                } else {\n                    mProgress.setVisibility(View.GONE);\n                }\n            }\n        });\n        // Create a JavaScript interface and bind the WebView to it.\n        mJSInterface = new JSInterface();\n        mWebView.addJavascriptInterface(mJSInterface, \"UnityInterface\");\n        // Start in invisible state.\n        mWebView.setVisibility(View.GONE);\n    }\n\n    public void updateWebView(final String lastRequestedUrl, final boolean loadRequest, final boolean visibility, final int leftMargin, final int topMargin, final int rightMargin, final int bottomMargin) {\n        // Process load requests.\n        if (lastRequestedUrl != null && (loadRequest || !mInitialLoad)) {\n            runOnUiThread(new Runnable() {\n                public void run() {\n                    mWebView.loadUrl(lastRequestedUrl);\n                }\n            });\n            mInitialLoad = true;\n        }\n        // Process changes in margin amounts.\n        if (leftMargin != mLeftMargin || topMargin != mTopMargin || rightMargin != mRightMargin || bottomMargin != mBottomMargin) {\n            mLeftMargin = leftMargin;\n            mTopMargin = topMargin;\n            mRightMargin = rightMargin;\n            mBottomMargin = bottomMargin;\n            runOnUiThread(new Runnable() {\n                public void run() {\n                    // Apply a new layout to the WebView.\n                    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.NO_GRAVITY);\n                    params.setMargins(mLeftMargin, mTopMargin, mRightMargin, mBottomMargin);\n                    mWebView.setLayoutParams(params);\n                }\n            });\n        }\n        // Process changes in visibility.\n        if (visibility != (mWebView.getVisibility() == View.VISIBLE)) {\n            runOnUiThread(new Runnable() {\n                public void run() {\n                    if (visibility) {\n                        // Show and set focus.\n                        mWebView.setVisibility(View.VISIBLE);\n                        mWebView.requestFocus();\n                    } else {\n                        // Hide.\n                        mWebView.setVisibility(View.GONE);\n                    }\n                }\n            });\n        }\n    }\n\n    public String pollWebViewMessage() {\n        return mJSInterface.mMessageQueue.poll();\n    }\n    \n    // Transparent background\n    public void makeTransparentWebViewBackground() {\n        mWebView.setBackgroundColor(Color.TRANSPARENT);\n    }\n} \n"
  },
  {
    "path": "unity/Assets/GUI/Default GUI SKin.guiskin.meta",
    "content": "fileFormatVersion: 1\nguid: ecaca87ebef4e4961ab66cf142175f61\n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont/Fonts/s1-mplus-1c-light.ttf.meta",
    "content": "fileFormatVersion: 1\nguid: 596c1fd1351a65540b8f6baeb5c83ccb\nTrueTypeFontImporter:\n  importerVersion: 1\n  size: 16\n  case: -1\n  antiAlias: 0\n  includeFontData: 1\n  use2xBehaviour: 0\n  style: 0\n  fontNames:\n    name: \n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont/Fonts.meta",
    "content": "fileFormatVersion: 1\nguid: 9e26e0c931f64c44799647ea7fd00b96\n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont/license.txt",
    "content": "﻿LICENSE\r\n\r\nThese fonts are free softwares. \r\nUnlimited permission is granted to use, copy, and distribute it, with or without modification, either commercially and noncommercially. \r\nTHESE FONTS ARE PROVIDED \"AS IS\" WITHOUT WARRANTY. \r\n\r\nこれらのフォントはフリー（自由な）ソフトウエアです。 \r\nあらゆる改変の有無に関わらず、また商業的な利用であっても、自由にご利用、複製、再配布することができますが、全て無保証とさせていただきます。 \r\n\r\n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont/license.txt.meta",
    "content": "fileFormatVersion: 1\nguid: 876dd09a256784345be2d6045b6571a3\n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont/readme.txt",
    "content": "﻿\r\nSelected U3D Japanese Fonts   05/17/2011\r\n\r\n------------------------------------------------------------------------\r\n# English\r\n\r\n  Selected U3D Japanese Fonts is based on M+OUTLINE Font TESTFLIGHT039 M+C.\r\n  Characters are selected so that it may fit in the optimal texture size for mobile devices.\r\n  It can have the characters of the size of 25 points in the 1024x1024 texture size.\r\n\r\n  The following groups are contained in this asset.\r\n\r\n  * Hiragana\r\n  * Katakana\r\n  * Alphabet , Number , Mark\r\n  * 1,006 Kanji taught in Japanese primary schools\r\n  * 132 Kanji in Japan states name and game words\r\n\r\n  All the lists of characters are recorded on \"list.txt\".\r\n\r\n  A question, a request, etc. to Selected U3D Japanese Fonts should inform the following address.\r\n    http://www.futurecartographer.com/\r\n    masashi_wada@dearna.com\r\n\r\n  Refer to the following URL for the details about M+OUTLINE Fonts. \r\n    http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html\r\n\r\n\r\n------------------------------------------------------------------------\r\n# Japanese ( 日本語 )\r\n\r\n  Selected U3D Japanese Fontsは M+OUTLINEフォントTESTFLIGHT039 M+Cを基盤にしています。\r\n  主にモバイル機器に最適な文字サイズとテクスチャサイズを両立するために、\r\n  フォントに含む文字を以下に限定して再構成したTTFファイルです。\r\n  これらの文字セットによって、1024x1024のテクスチャであっても、25ポイントまでの大きさを保てる特徴があります。\r\n\r\n  ・ひらがな\r\n  ・カタカナ\r\n  ・アルファベット、数字、記号\r\n  ・小学校６年生までの教育漢字(1006文字)\r\n  ・都道府県表記、ゲーム用語に適した漢字 (132文字)\r\n\r\n  フォントに含まれる全ての文字のリストは list.txt に記載しています。\r\n\r\n　Selected U3D Japanese Fontsに関する質問、要望などは次のアドレスに連絡をしてください。\r\n    http://www.futurecartographer.com/\r\n    masashi_wada@dearna.com\r\n\r\n  M+OUTLINEフォントに関する詳細は次のURLを参照してください。\r\n    http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index.html\r\n\r\n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont/readme.txt.meta",
    "content": "fileFormatVersion: 1\nguid: 4a4f1ada9e7459344bc4acb002b22a4b\n"
  },
  {
    "path": "unity/Assets/GUI/SU3DJPFont.meta",
    "content": "fileFormatVersion: 1\nguid: 2c7ff880dcb39c14199433ad6846d37b\n"
  },
  {
    "path": "unity/Assets/GUI.meta",
    "content": "fileFormatVersion: 1\nguid: 3a3b1c6f5244d498e95e41026452dc53\n"
  },
  {
    "path": "unity/Assets/Main.unity.meta",
    "content": "fileFormatVersion: 1\nguid: 5dd8fad3f211b4f50aaee8743a63da4e\n"
  },
  {
    "path": "unity/Assets/Materials/Blue Box.mat.meta",
    "content": "fileFormatVersion: 1\nguid: 905886db109bd4a36af150540c0bd0f1\n"
  },
  {
    "path": "unity/Assets/Materials/Floor.mat.meta",
    "content": "fileFormatVersion: 1\nguid: e06bb986f1a7e4dc6841f7cb59aeef8e\n"
  },
  {
    "path": "unity/Assets/Materials/Red Box.mat.meta",
    "content": "fileFormatVersion: 1\nguid: ac8ade9aa523842fab3b893be999d08e\n"
  },
  {
    "path": "unity/Assets/Materials.meta",
    "content": "fileFormatVersion: 1\nguid: eacdd09aa755f4bf6b6531b7af53dad5\n"
  },
  {
    "path": "unity/Assets/Physics/Default Physic Material.physicMaterial.meta",
    "content": "fileFormatVersion: 1\nguid: daef168d6938746eda86db30cd78df40\n"
  },
  {
    "path": "unity/Assets/Physics.meta",
    "content": "fileFormatVersion: 1\nguid: 046d56fdea7e34d05bbe1082f55a769d\n"
  },
  {
    "path": "unity/Assets/Plugins/Android/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"jp.radiumsoftware.unitywebviewexample\"\n\tandroid:installLocation=\"preferExternal\"\n    android:versionCode=\"1\"\n    android:versionName=\"1.0\">\n    <supports-screens\n        android:smallScreens=\"true\"\n        android:normalScreens=\"true\"\n        android:largeScreens=\"true\"\n        android:xlargeScreens=\"true\"\n        android:anyDensity=\"true\"/>\n\n    <application\n\t\tandroid:icon=\"@drawable/app_icon\"\n        android:label=\"@string/app_name\"\n        android:debuggable=\"true\">\n        <activity android:name=\".ExtendedUnityPlayerActivity\"\n                  android:label=\"@string/app_name\"\n                  android:configChanges=\"fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n</manifest>\n"
  },
  {
    "path": "unity/Assets/Plugins/Android/AndroidManifest.xml.meta",
    "content": "fileFormatVersion: 1\nguid: 50bf13cedd20a49f3b2ef3e88cf13d4f\n"
  },
  {
    "path": "unity/Assets/Plugins/Android/WebViewIntegration.jar.meta",
    "content": "fileFormatVersion: 1\nguid: 94d9591b24ce3471383b7b7f121cb653\n"
  },
  {
    "path": "unity/Assets/Plugins/Android.meta",
    "content": "fileFormatVersion: 1\nguid: 22aac9bb108084be8b2ffc5ec762342e\n"
  },
  {
    "path": "unity/Assets/Plugins/WebMediator.js",
    "content": "#pragma strict\n\n// WebView-Unity mediator plugin script.\n\nimport System.Runtime.InteropServices;\n\n// Message container class.\nclass WebMediatorMessage {\n    var path : String;      // Message path\n    var args : Hashtable;   // Argument table\n\n    function WebMediatorMessage(rawMessage : String) {\n        // Retrieve a path.\n        var split = rawMessage.Split(\"?\"[0]);\n        path = split[0];\n        // Parse arguments.\n        args = new Hashtable();\n        if (split.Length > 1) {\n            for (var pair in split[1].Split(\"&\"[0])) {\n                var elems = pair.Split(\"=\"[0]);\n                args[elems[0]] = WWW.UnEscapeURL(elems[1]);\n            }\n        }\n    }\n}\n\nprivate static var instance : WebMediator;\nprivate static var isClearCache : boolean;\n\nprivate var lastRequestedUrl : String;\nprivate var loadRequest : boolean;\nprivate var visibility : boolean;\nprivate var leftMargin : int;\nprivate var topMargin : int;\nprivate var rightMargin : int;\nprivate var bottomMargin : int;\n\n// Install the plugin.\n// Call this at least once before using the plugin.\nstatic function Install() {\n    if (instance == null) {\n        var master = new GameObject(\"WebMediator\");\n        DontDestroyOnLoad(master);\n        instance = master.AddComponent.<WebMediator>();\n        InstallPlatform();\n    }\n}\n\n// Set margins around the web view.\nstatic function SetMargin(left : int, top: int, right : int, bottom : int) {\n    instance.leftMargin = left;\n    instance.topMargin = top;\n    instance.rightMargin = right;\n    instance.bottomMargin = bottom;\n    ApplyMarginsPlatform();\n}\n\n// Visibility functions.\nstatic function Show() {\n    instance.visibility = true;\n}\nstatic function Hide() {\n    instance.visibility = false;\n}\nstatic function IsVisible() {\n    return instance.visibility;\n}\n\nstatic function SetClearCache()\n{\n    isClearCache = true;\n}\n\nstatic function SetCache()\n{\n    isClearCache = false;\n}\n\n// Load the page at the URL.\nstatic function LoadUrl(url : String) {\n    instance.lastRequestedUrl = url;\n    instance.loadRequest = true;\n}\n\nfunction Update() {\n    UpdatePlatform();\n    instance.loadRequest = false;\n}\n\n#if UNITY_EDITOR\n\n// Unity Editor implementation.\n\nprivate static function InstallPlatform() { }\nprivate static function UpdatePlatform() { }\nprivate static function ApplyMarginsPlatform() { }\nstatic function PollMessage() : WebMediatorMessage { return null; }\nstatic function MakeTransparentWebViewBackground() { }\n\n#elif UNITY_IPHONE\n\n// iOS platform implementation.\n\n@DllImportAttribute(\"__Internal\") static private function _WebViewPluginInstall() {}\n@DllImportAttribute(\"__Internal\") static private function _WebViewPluginLoadUrl(url : String, isClearCache : boolean) {}\n@DllImportAttribute(\"__Internal\") static private function _WebViewPluginSetVisibility(visibility : boolean) {}\n@DllImportAttribute(\"__Internal\") static private function _WebViewPluginSetMargins(left : int, top : int, right : int, bottom : int) {}\n@DllImportAttribute(\"__Internal\") static private function _WebViewPluginPollMessage() : String {}\n@DllImportAttribute(\"__Internal\") static private function _WebViewPluginMakeTransparentBackground() {}\n\nprivate static var viewVisibility : boolean;\n\nprivate static function InstallPlatform() {\n    _WebViewPluginInstall();\n}\n\nprivate static function ApplyMarginsPlatform() {\n    _WebViewPluginSetMargins(instance.leftMargin, instance.topMargin, instance.rightMargin, instance.bottomMargin);\n}\n\nprivate static function UpdatePlatform() {\n    if (viewVisibility != instance.visibility) {\n        viewVisibility = instance.visibility;\n        _WebViewPluginSetVisibility(viewVisibility);\n    }\n    if (instance.loadRequest) {\n        instance.loadRequest = false;\n        _WebViewPluginLoadUrl(instance.lastRequestedUrl, isClearCache);\n    }\n}\n\nstatic function PollMessage() : WebMediatorMessage {\n    var message =  _WebViewPluginPollMessage();\n    return message ? new WebMediatorMessage(message) : null;\n}\n\nstatic function MakeTransparentWebViewBackground()\n{\n    _WebViewPluginMakeTransparentBackground();\n}\n\n#elif UNITY_ANDROID\n\n// Android platform implementation.\n\nprivate static var unityPlayerClass : AndroidJavaClass;\n\nprivate static function InstallPlatform() {\n    unityPlayerClass = new AndroidJavaClass(\"com.unity3d.player.UnityPlayer\");\n}\n\nprivate static function ApplyMarginsPlatform() { }\n\nprivate static function UpdatePlatform() {\n    var activity = unityPlayerClass.GetStatic.<AndroidJavaObject>(\"currentActivity\");\n    activity.Call(\"updateWebView\", instance.lastRequestedUrl ? instance.lastRequestedUrl : \"\", instance.loadRequest, instance.visibility, instance.leftMargin, instance.topMargin, instance.rightMargin, instance.bottomMargin);\n}\n\nstatic function PollMessage() : WebMediatorMessage {\n    var activity = unityPlayerClass.GetStatic.<AndroidJavaObject>(\"currentActivity\");\n    var message = activity.Call.<String>(\"pollWebViewMessage\");\n    return message ? new WebMediatorMessage(message) : null;\n}\n\nstatic function MakeTransparentWebViewBackground()\n{\n    var activity = unityPlayerClass.GetStatic.<AndroidJavaObject>(\"currentActivity\");\n    activity.Call(\"makeTransparentWebViewBackground\");\n}\n\n#endif\n"
  },
  {
    "path": "unity/Assets/Plugins/WebMediator.js.meta",
    "content": "fileFormatVersion: 1\nguid: 9b61fa8dd1f9f40d9a0788beb93cd400\n"
  },
  {
    "path": "unity/Assets/Plugins/iOS/WebViewPlugin.mm",
    "content": "// Web view integration plug-in for Unity iOS.\n\n#import <Foundation/Foundation.h>\n\nextern UIViewController *UnityGetGLViewController(); // Root view controller of Unity screen.\n\n#pragma mark Plug-in Functions\n\nstatic UIWebView *webView;\n\nextern \"C\" void _WebViewPluginInstall() {\n    // Add the web view onto the root view (but don't show).\n    UIViewController *rootViewController = UnityGetGLViewController();\n    webView = [[UIWebView alloc] initWithFrame:rootViewController.view.frame];\n    webView.hidden = YES;\n    [rootViewController.view addSubview:webView];\n}\n\nextern \"C\" void _WebViewPluginMakeTransparentBackground() {\n    [webView setBackgroundColor:[UIColor clearColor]];\n    [webView setOpaque:NO];\n}\n\nextern \"C\" void _WebViewPluginLoadUrl(const char* url, boolean isClearCache) {\n    if (isClearCache) {\n        [[NSURLCache sharedURLCache] removeAllCachedResponses];\n    }\n    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]]];\n}\n\nextern \"C\" void _WebViewPluginSetVisibility(bool visibility) {\n    webView.hidden = visibility ? NO : YES;\n}\n\nextern \"C\" void _WebViewPluginSetMargins(int left, int top, int right, int bottom) {\n    UIViewController *rootViewController = UnityGetGLViewController();\n    \n    CGRect frame = rootViewController.view.frame;\n    CGFloat scale = rootViewController.view.contentScaleFactor;\n    \n    CGRect screenBound = [[UIScreen mainScreen] bounds];\n    CGSize screenSize = screenBound.size;\n    // Obtaining the current device orientation\n    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];\n    \n    // landscape\n    if (orientation) {\n        frame.size.width = screenSize.height - (left + right) / scale;\n        frame.size.height = screenSize.width - (top + bottom) / scale;\n    } else { // portrait\n        frame.size.width = screenSize.width - (left + right) / scale;\n        frame.size.height = screenSize.height - (top + bottom) / scale;\n    }\n    \n    frame.origin.x += left / scale;\n    frame.origin.y += top / scale;\n\n    webView.frame = frame;\n}\n\nextern \"C\" char *_WebViewPluginPollMessage() {\n    // Try to retrieve a message from the message queue in JavaScript context.\n    NSString *message = [webView stringByEvaluatingJavaScriptFromString:@\"unityWebMediatorInstance.pollMessage()\"];\n    if (message && message.length > 0) {\n        NSLog(@\"UnityWebViewPlugin: %@\", message);\n        char* memory = static_cast<char*>(malloc(strlen(message.UTF8String) + 1));\n        if (memory) strcpy(memory, message.UTF8String);\n        return memory;\n    } else {\n        return NULL;\n    }\n}\n"
  },
  {
    "path": "unity/Assets/Plugins/iOS/WebViewPlugin.mm.meta",
    "content": "fileFormatVersion: 2\nguid: 4fd761aa32d674f48b76101ac5cf8971\n"
  },
  {
    "path": "unity/Assets/Plugins/iOS.meta",
    "content": "fileFormatVersion: 2\nguid: 9bde65d35751a4fa88830f764562c2bb\n"
  },
  {
    "path": "unity/Assets/Plugins.meta",
    "content": "fileFormatVersion: 1\nguid: 04a4b0667591a44f6a9cc634795749cf\n"
  },
  {
    "path": "unity/Assets/Prefabs/Blue Box.prefab.meta",
    "content": "fileFormatVersion: 1\nguid: c1a1ab85a23cd4ce1bdd3731ac0ab9dd\n"
  },
  {
    "path": "unity/Assets/Prefabs/Red Box.prefab.meta",
    "content": "fileFormatVersion: 1\nguid: 74768062b89004afb801f11a7a523ca1\n"
  },
  {
    "path": "unity/Assets/Prefabs.meta",
    "content": "fileFormatVersion: 1\nguid: 9eb3019c10b364779925ef1ec161fb47\n"
  },
  {
    "path": "unity/Assets/Scripts/Box.js",
    "content": "#pragma strict\n\nfunction Update() {\n    if (transform.position.y < -2.0) Destroy(gameObject);\n}\n"
  },
  {
    "path": "unity/Assets/Scripts/Box.js.meta",
    "content": "fileFormatVersion: 1\nguid: 5f957e7e7cda347e0bbfaf9c31ec781d\n"
  },
  {
    "path": "unity/Assets/Scripts/TestInterface.js",
    "content": "#pragma strict\n\nvar guiSkin : GUISkin;\nvar redBoxPrefab : GameObject;\nvar blueBoxPrefab : GameObject;\n\nprivate var note : String;\n\n// Show the web view (with margins) and load the index page.\nprivate function ActivateWebView() {\n    WebMediator.LoadUrl(\"http://keijiro.github.com/unity-webview-integration/index.html\");\n    WebMediator.SetMargin(12, Screen.height / 2 + 12, 12, 12);\n    WebMediator.Show();\n}\n\n// Hide the web view.\nprivate function DeactivateWebView() {\n    WebMediator.Hide();\n    // Clear the state of the web view (by loading a blank page).\n    WebMediator.LoadUrl(\"about:blank\");\n}\n\n// Process messages coming from the web view.\nprivate function ProcessMessages() {\n    while (true) {\n        // Poll a message or break.\n        var message = WebMediator.PollMessage();\n        if (!message) break;\n\n        if (message.path == \"/spawn\") {\n            // \"spawn\" message.\n            if (message.args.ContainsKey(\"color\")) {\n                var prefab = (message.args[\"color\"] == \"red\") ? redBoxPrefab : blueBoxPrefab;\n            } else {\n                prefab = Random.value < 0.5 ? redBoxPrefab : blueBoxPrefab;\n            }\n            var box = Instantiate(prefab, redBoxPrefab.transform.position, Random.rotation) as GameObject; \n            if (message.args.ContainsKey(\"scale\")) {\n                box.transform.localScale = Vector3.one * float.Parse(message.args[\"scale\"] as String);\n            }\n        } else if (message.path == \"/note\") {\n            // \"note\" message.\n            note = message.args[\"text\"] as String;\n        } else if (message.path == \"/print\") {\n            // \"print\" message.\n            var text = message.args[\"line1\"] as String;\n            if (message.args.ContainsKey(\"line2\")) {\n                text += \"\\n\" + message.args[\"line2\"] as String;\n            }\n            Debug.Log(text);\n            Debug.Log(\"(\" + text.Length + \" chars)\");\n        } else if (message.path == \"/close\") {\n            // \"close\" message.\n            DeactivateWebView();\n        }\n    }\n}\n\nfunction Start() {\n    WebMediator.Install();\n}\n\nfunction Update() {\n    if (WebMediator.IsVisible()) {\n        ProcessMessages();\n    } else if (Input.GetButtonDown(\"Fire1\") && Input.mousePosition.y < Screen.height / 2) {\n        ActivateWebView();\n    }\n}\n\nfunction OnGUI() {\n    var sw = Screen.width;\n    var sh = Screen.height;\n    GUI.skin = guiSkin;\n    if (note) GUI.Label(Rect(0, 0, sw, 0.5 * sh), note);\n    GUI.Label(Rect(0, 0.5 * sh, sw, 0.5 * sh), \"TAP HERE\", \"center\");\n}\n"
  },
  {
    "path": "unity/Assets/Scripts/TestInterface.js.meta",
    "content": "fileFormatVersion: 1\nguid: de41a1264b5be41c48fa4a0b821508b2\n"
  },
  {
    "path": "unity/Assets/Scripts.meta",
    "content": "fileFormatVersion: 1\nguid: 6f9ab5fa22bd84d038705e7f6d302a8f\n"
  },
  {
    "path": "unity/Assets/Textures/Board.png.meta",
    "content": "fileFormatVersion: 1\nguid: b9953bd5259dc48cc95acccd0f8c1228\nTextureImporter:\n  importerVersion: 1\n  maxTextureSize: 1024\n  textureFormat: -1\n  grayscaleToAlpha: 0\n  npotScale: 1\n  generateCubemap: 0\n  isReadable: 0\n  mipmaps:\n    generation: 1\n    correctGamma: 0\n    border: 0\n    filter: 0\n    fadeout: 0\n    fadeoutStart: 1\n    fadeoutEnd: 3\n  bumpmap:\n    generation: 0\n    bumpyness: 0.25\n    filter: 0\n  textureSettings:\n    filterMode: -1\n    anisoLevel: -1\n    mipmapBias: -1\n    wrapMode: -1\n"
  },
  {
    "path": "unity/Assets/Textures/Checker2.png.meta",
    "content": "fileFormatVersion: 1\nguid: a94bba682ebe648c08416aff1b18ad2e\nTextureImporter:\n  importerVersion: 2\n  maxTextureSize: 1024\n  textureFormat: -1\n  grayscaleToAlpha: 0\n  npotScale: 1\n  generateCubemap: 0\n  isReadable: 0\n  textureType: 0\n  mipmaps:\n    generation: 1\n    correctGamma: 0\n    border: 0\n    filter: 0\n    fadeout: 0\n    fadeoutStart: 1\n    fadeoutEnd: 3\n  bumpmap:\n    generation: 0\n    bumpyness: 0.25\n    filter: 0\n  textureSettings:\n    filterMode: -1\n    anisoLevel: -1\n    mipmapBias: -1\n    wrapMode: -1\n  buildTargetSettings:\n    iPhone:\n      maxTextureSize: 128\n      textureFormat: -3\n"
  },
  {
    "path": "unity/Assets/Textures.meta",
    "content": "fileFormatVersion: 1\nguid: 28e2e9674dd404ef6ab51022aef57fc0\n"
  }
]