Reputation: 3997
I am doing a game application using unity3d for Android. In that I popup one alert box, which will show some message like "Do you want to proceed click 'OK' or 'Cancel'". If the user clicks "ok" I want to forword them to some webpage like 'https://stackoverflow.com/' .
This is possible in android using "Webview" android code. Now my question is How can I use this webview in Unity3d(C# code).
I have searched over the net and got the following links:
https://github.com/gree/unity-webview
https://github.com/kimsama/unity3d-webview-csharp
I have downloaded these codes. But I couldn't execute these samples. If anyone used these samples, Please give me the steps to execute these? or can anybody give other samples will be helpful to me.
Upvotes: 4
Views: 19980
Reputation: 26
My team had this same case, except we wanted something that works with both 2D and 3D. We looked at different options and ended up using the Unity 3D WebView plugin. Here's what our code looks like:
void ShowWebView(Vector3 position) {
var webPrefab = WebViewPrefab.Instantiate(0.5f, 0.5f); // specify the size
webPrefab.transform.parent = this.transform;
webPrefab.transform.position = position;
webPrefab.transform.LookAt(Camera.main.transform);
webPrefab.Initialized += (sender, e) => webPrefab.WebView.LoadUrl("https://example.com");
}
Upvotes: 1
Reputation: 4631
I made a similar WebView plugin based on gree's webview, in which I modified some code to let it run in Mac Editor (and of course you can use it in both iOS and Android). There is also a valid demo for you in the repo. You can try it.
UniWebView - a Unity3D webview plugin for iOS, Android and Mac
Upvotes: 4