macOS X 上のUnity2018.3.6f1でWebViewを実行しようと考え、プロジェクトを作成し、git(https://github.com/gree/unity-webview)より取得したzipより
dist/unity-webview.unitypackage
をプロジェクトにドロップして必要なソースを取得し、HierarcyにWebView用等のオブジェクトを作成し以下のようにソースを組んでオブジェクトに付与しました。
C#
1using UnityEngine; 2 3public class SampleWebView : MonoBehaviour 4{ 5 private string url = "http://www.google.com/"; 6 WebViewObject webViewObject; 7 8 void Start() 9 { 10 webViewObject = 11 (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); 12 webViewObject.Init((msg) => { 13 if (msg == "clicked") 14 { 15 webViewObject.SetVisibility(false); 16 } 17 }); 18 19 webViewObject.LoadURL(url); 20 21 webViewObject.SetMargins(50, 100, 50, 50); 22 23 webViewObject.SetVisibility(true); 24 25 webViewObject.EvaluateJS( 26 "window.addEventListener('load', function() {" + 27 " window.addEventListener('click', function() {" + 28 " Unity.call('clicked');" + 29 " }, false);" + 30 "}, false);"); 31 32 } 33 34 void OnGUI() 35 { 36 Rect textArea = new Rect(100, 0, 400, 100); 37 url = GUI.TextArea(textArea, url); 38 39 if (GUI.Button(new Rect(500, 0, 100, 100), "GO")) 40 { 41 webViewObject.LoadURL(url); 42 webViewObject.SetVisibility(true); 43 } 44 } 45}
しかし、毎回Unityでクラッシュが発生してしまいます。
ソースを辿ったところ、 webViewObject.SetVisibility(true); でクラッシュは発生しており、エラーログを見てみると以下のようなクラッシュログが残っておりました
Reloading assemblies for play mode. Begin MonoManager ReloadAssembly Initializing Unity.PackageManager (PackageManager) v2018.3.6 for Unity v2018.3.6f1 Registering platform support modules: Registered platform support modules in: 0.0540608s. Native extension for Android target not found Native extension for iOS target not found Native extension for OSXStandalone target not found Refreshing native plugins compatible for Editor in 2.58 ms, found 4 plugins. Preloading 1 native plugins for Editor in 1.31 ms. Mono: successfully reloaded assembly - Completed reload, in 1.416 seconds Platform modules already initialized, skipping Load scene 'Temp/__Backupscenes/0.backup' time: 0.279816 ms Refreshing native plugins compatible for Editor in 0.49 ms, found 4 plugins. Fallback handler could not load library /Applications/Unity/Hub/Editor/2018.3.6f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/WebView.bundle/Contents/MacOS/WebView Fallback handler could not load library /Applications/Unity/Hub/Editor/2018.3.6f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/WebView.bundle/Contents/MacOS/WebView.dylib Fallback handler could not load library /Applications/Unity/Hub/Editor/2018.3.6f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/WebView.bundle/Contents/MacOS/WebView.so Fallback handler could not load library /Applications/Unity/Hub/Editor/2018.3.6f1/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/WebView.bundle/Contents/MacOS/WebView.bundle Receiving unhandled NULL exception Obtained 12 stack frames. Thread 0x700014e99000 may have been prematurely finalized #0 0x007fff50c9ac44 in glGetIntegerv Thread 0x700014e99000 may have been prematurely finalized #1 0x00000123c9c96c in -[CWebViewPlugin render] Thread 0x700014e99000 may have been prematurely finalized #2 0x00000123c9d185 in UnityRenderEvent Thread 0x700014e99000 may have been prematurely finalized #3 0x00000100fcb16f in GfxDevice::InsertCustomMarkerCallback(void (*)(int), int) Thread 0x700014e99000 may have been prematurely finalized #4 0x00000102a5d8a9 in GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&) Thread 0x700014e99000 may have been prematurely finalized #5 0x0000010078f08c in GfxDeviceWorkerAutoreleasePoolProxy Thread 0x700014e99000 may have been prematurely finalized #6 0x00000102a654c0 in GfxDeviceWorker::RunExt(ThreadedStreamBuffer&) Thread 0x700014e99000 may have been prematurely finalized #7 0x00000102a5af51 in GfxDeviceWorker::RunGfxDeviceWorker(void*) Thread 0x700014e99000 may have been prematurely finalized #8 0x00000100e69542 in Thread::RunThreadWrapper(void*) Thread 0x700014e99000 may have been prematurely finalized #9 0x007fff6f546661 in _pthread_body Thread 0x700014e99000 may have been prematurely finalized #10 0x007fff6f54650d in _pthread_body Thread 0x700014e99000 may have been prematurely finalized #11 0x007fff6f545bf9 in thread_start Launching bug reporter (中略) Assertion failed on expression: 'Thread::EqualsCurrentThreadID(Thread::mainThreadId)' (Filename: /Users/builduser/buildslave/unity/build/Editor/Src/SceneInspector.cpp Line: 532
これはどのような事象、あるいは設定ミスが考えられますでしょうか?
よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。