Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UniWebView - Integrating WebView to your mobile games in a simple way

Discussion in 'Assets and Asset Store' started by onevcat, Nov 14, 2013.

  1. IOZO

    IOZO

    Joined:
    Jun 26, 2010
    Posts:
    55
    Can I render a web view as a UI component ?
     
  2. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    How far out is editor support on windows? I had bought old version but will gladly update and leave good review if this gets done soon.
     
  3. MochiBits

    MochiBits

    Joined:
    Mar 11, 2014
    Posts:
    30
    Is there a way to enable the scrollbar for iOS?
     
  4. ILLUSION-THAI

    ILLUSION-THAI

    Joined:
    Sep 21, 2015
    Posts:
    3
    iOS 9 not work how to fix it.
     
  5. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    So the website I wish to open has mobile iOS support, but using the kit you failed to mention that opening the website it does not resize to users mobile screen or use the websites mobile template?
    Is there a way to do this?
     
  6. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    It should work automatically if you have correct responsive design on your site. May I know how did you do to support mobile for your mobile?

    And you could also try to visit some site which optimized for mobile (Unity 3d official page https://unity3d.com or Stackoverflow https://stackoverflow.com are both good examples) to see how it works in action.
     
  7. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I just tried Unity website and same problem. Tested in Editor (iPhone 5 Portrait) Using Unity 5.3
    So the issue is not to do with the website.
    Try it yourself and see!
     
  8. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    Please updated to the latest version and try again. There was a fix on editor scale recently. Please make sure you are using the latest package and there should be a "SetUserAgent" call to set the web view agent to iPhone in file UniWebViewPluginMacEditor to simulate a phone.

    And if you are checking the screen size to decide the layout, you may need to make your player screen smaller (not full screen on play, in other word), since your site will get the size of your actual editor player instead of a standard mobile display size.
     
  9. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    But I'm running Unity 5.3.1p3 and using your latest plugin (Version: 2.5.0 (Jan 05, 2016)
    Do I need to manually do some editing?
    I tested in Editor Mac OSX and on iPhone and site remained the same and not to scale.

    Code (CSharp):
    1.  if (Application.platform == RuntimePlatform.OSXEditor) {
    2.             if (!_connected) {
    3.                 ConnectNativeBundle();
    4.                 SetUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 9_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A344 Safari/601.1");
     
  10. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    Not quite sure what happened. It work for me well in both Editor and real device. The only thing I noticed is you are using Unity 5.3.1p3 while mine is Unity 5.3.1f1. However, it should not be different for the patch version. I will try p3 as well later and let you know the result.

    And would you like to try the demo scenes and/or in a clean project instead of the one you are working on now?

    I attached a screenshot to show it, by using the demo scene 2 in the bundle.

     

    Attached Files:

  11. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Yes indeed it seems to be working for you, did you convert the project to iOS and try on mobile device settings?
    Yes I did clean project and used your demo, just changed the URL link.
     
  12. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    Yes, I am using iOS in build setting.

    The Internet turns to be quite slow for me currently, so I have a no chance to test it in Unity 5.3.1p3 yet.
    Have no idea on what's wrong now.

    What device you are using to try it?
     
  13. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    And just did a test in Unity 5.3.1p4, cannot reproduce it as well.
     
  14. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    ...still curious about this. I am asking about windows editor support like you have for mac editor. When can we expect that?
     
  15. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Hi, so I created a new project and downloaded 5.3.1p4 - changed project to iOS.

    I then went to Basic, and Just run the Basic scene, no code change at all, see my screenshot below:



    Do you know what I'm doing wrong then?

    Only other thing maybe because I'm using a Mac machine?
     
  16. Leoxi

    Leoxi

    Joined:
    Apr 25, 2014
    Posts:
    5
    there is a issue :OrientationSupport.h not found.how to fix it;
    unity 4.6.9
    xcode 7.2
     
  17. Delaley

    Delaley

    Joined:
    Jan 19, 2016
    Posts:
    6
    Unity 4.6 javascript embedded not loading neither is the external Image url. Basically the button is unclickable.
     
  18. TrophyManager

    TrophyManager

    Joined:
    Sep 9, 2015
    Posts:
    15
    SInce WP8 and WSA8 are no longer Unity 5.3 targets
    Is there any way to use UniWebView with in WIndows at this moment:
    • WSA 8.1
    • WP 8.1
    • Windows universal 8.1
    • Windows Universal 10
    Thank you
     
  19. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Does this support Vimeo playback on Android? I am having issues with UniWebView 2 on a Galaxy S6. The web page loads, but when playing a video I see black and can hear the audio.
     
  20. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Any thoughts on the above comment? Really need a solution for this...
     
  21. Vern_Shurtz

    Vern_Shurtz

    Joined:
    Mar 6, 2009
    Posts:
    264
    Thank you for a great asset. Works quite well in my project. The one thing I am trying to figure out is knowing when the user is done and has closed the web view. Is there a way to detect if web view is open in Unity and when it is closed?
     
  22. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hey There !
    I am in a trouble because of your asset.
    I am changing screen orientation of my Game through script in which UniWebView has been used.
    My Game has two scene, The Menu contains UniWebview Related Stuff and My game is in Landscape mode.
    When I load landscape mode scene it works in android but in iOS it just don't rotate the screeen in Landscape mode.
    This is because of UniWebView as I am not using any other asset right now. I have created a Dummy project in which I am changing screen orientation without uniwebview and is working fine.
    Any remedies for my issue :( Any Solutions ? any workarounds? Please
     
  23. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    On iOS for orientation support, you need to delete the include of at the top for orientation support, then CMD+click on orientation support (the line failing) you jump to a function copy the whole function and delete the second argument (also the if at the end using this parameter) and you are done IIRC.


    By the way, how to debug loaded urls??? OnComplete, I get incomplete, but see my screen white (not showing contents) there are other places in the same app that I use it same way and it show the contents correctly, but this specific case not.
     
  24. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hi Tyoc213!
    I really appreciate your help!
    But can you please illustrate it little bit more. ? Please I am trying to figure it out from a long time with no success !

    I mean do I have to delete in OrientationSupport or in UniWebView.mm????
     
    Last edited: Mar 16, 2016
  25. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    Well you need to make the Xcode project (or you can modify the source of uniwebview) and inside the project

    1. Delete the offending line #include "OrientationSupport.h" in UniWebView.mm
    2. Now the problem is that there is no function/method for orientation support, luckily you can CMD+click and you will be redirected to a function, copy this function back to UniWebView.mm and delete the second argument and the if inside this function

    You are done for let uniwebview compile.


    In fact the function you will copy and modify at the end will look like

    Code (CSharp):
    1. ScreenOrientation ConvertToUnityScreenOrientation(UIInterfaceOrientation hwOrient)
    2. {
    3.     EnabledOrientation autorotOrient     = autorotPortrait;
    4.     ScreenOrientation  unityScreenOrient = portrait;
    5.    
    6.     switch (hwOrient)
    7.     {
    8.         case UIInterfaceOrientationPortrait:
    9.             autorotOrient     = autorotPortrait;
    10.             unityScreenOrient = portrait;
    11.             break;
    12.         case UIInterfaceOrientationPortraitUpsideDown:
    13.             autorotOrient     = autorotPortraitUpsideDown;
    14.             unityScreenOrient = portraitUpsideDown;
    15.             break;
    16.             // landscape left/right have switched values in device/screen orientation
    17.             // though unity docs are adjusted with device orientation values, so swap here
    18.         case UIInterfaceOrientationLandscapeLeft:
    19.             autorotOrient     = autorotLandscapeRight;
    20.             unityScreenOrient = landscapeRight;
    21.             break;
    22.         case UIInterfaceOrientationLandscapeRight:
    23.             autorotOrient     = autorotLandscapeLeft;
    24.             unityScreenOrient = landscapeLeft;
    25.             break;
    26.     }
    27.    
    28.     return unityScreenOrient;
    29. }
     
  26. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hey that is really very much appreciated.
    But can you let me know which version of UniWebView are you referring to?
    Also which version of Unity are you using? I have this code in my OrientationSupport to which I found by cmd click. like you said
    Code (CSharp):
    1. ScreenOrientation ConvertToUnityScreenOrientation(UIInterfaceOrientation orient)
    2. {
    3.     switch(orient)
    4.     {
    5.         case UIInterfaceOrientationPortrait:            return portrait;
    6.         case UIInterfaceOrientationPortraitUpsideDown:    return portraitUpsideDown;
    7.         // landscape left/right have switched values in device/screen orientation
    8.         // though unity docs are adjusted with device orientation values, so swap here
    9.         case UIInterfaceOrientationLandscapeLeft:        return landscapeRight;
    10.         case UIInterfaceOrientationLandscapeRight:        return landscapeLeft;
    11.  
    12. #pragma clang diagnostic push
    13. #pragma clang diagnostic ignored "-Wswitch"
    14.         case UIInterfaceOrientationUnknown:                return orientationUnknown;
    15. #pragma clang diagnostic pop
    16.  
    17.         default:                                        return portrait;
    18.     }
    19. }
    I am using uniwebview 2.7 and Unity 5.3.3 and xcode 7.2 on el capitan (if needed at all)
     
  27. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    O well, right now Im using unity 4.6.p9 (I guess that is why the orientation support is different) and version 2 of uniwebview.


    Mmmmm, what problem are you having exactly on 5.3?
     
  28. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    As I mentioned. My issue is that main menu of my project is in portrait mode. and I have 3 mini games which can be accessed from the portrait mode Main menu. 3 games and 1 menu, all are in separate scenes. One of the 3 games is in Landscape mode. issue starts now, The game that should be in Landscape mode is not starting in Landscape mode. Instead it just like it ignores the orientation change call.
    Code (CSharp):
    1. Screen.orientation = ScreenOrientation.LandscapeLeft;
    The Same thing works fine in android, also If I remove UniWebView Package then the iOS version also works fine as expected. i.e changes Screen Orientation to Landscape in game and back to portrait in Main Menu. So UniWebView is actually the culprit, but I need it to show webpages in My Main Menu. It's actually a Learning game with different web pages and 3 games for kids. Any one can help will be much appreciated.
     
  29. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    I remember having problems with rotation (but in general of unity)... so we decided to let the whole thing rotate all the way (no special cases or orientations for special windows).
     
  30. Mr-Blue825

    Mr-Blue825

    Joined:
    Oct 8, 2012
    Posts:
    30
    Hi,

    I tried to use the Demo in the package, but at the end of the countdown it does nothing. It appears in the hierarchy but nothing on the screen change.
    I am targetting Android platform.



    What is wrong ?
    Thanks for your help.
     
  31. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hi Uni Webview team?

    I got this Warning, When I submitted my app on Google Play !
    Your app(s) listed at the end of this email have an unsafe implementation of the WebViewClient.onReceivedSslError handler. Specifically, the implementation ignores all SSL certificate validation errors, making your app vulnerable to man-in-the-middle attacks. An attacker could change the affected WebView's content, read transmitted data (such as login credentials), and execute code inside the app using JavaScript.​

    Please address this vulnerability as soon as possible and increment the version number of the upgraded APK. To properly handle SSL certificate validation, change your code to invoke SslErrorHandler.proceed() whenever the certificate presented by the server meets your expectations, and invoke SslErrorHandler.cancel() otherwise. If you are using a 3rd party library that’s responsible for this, please notify the 3rd party and work with them to address the issue.

    For more information about the SSL error handler, please see our documentation in the Android Developers Help Center. For other technical questions, you can post to Stack Overflow and use the tags “android-security” and “SslErrorHandler.”

    To confirm you’ve upgraded correctly, submit the updated version to the Developer Console and check back after five hours. If the app hasn’t been upgraded correctly, we will display a warning.

    While these specific issues may not affect every app that uses WebView SSL, it’s best to stay up to date on all security patches. Apps with vulnerabilities that expose users to risk of compromise may be considered to be in violation of the Malicious Behavior policy and section 4.4 of the Developer Distribution Agreement.
    Affected app(s), version(s), and class(es):

    com.imagineworld.HarmonyHouse
    1
    com.onevcat.uniwebview.UniWebViewDialog$2;​
     
    Last edited: May 4, 2016
  32. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    Mr Blue, you can't check uniwebview on the editor, you will need to deploy to device...


    ------

    By the way, with the switch of drop of the Windows phone SDK instead unity has choose windows store apps where you select your target device, now unity complain there is no UniWebview class can't be found... some one of you what I need to change for this new setup??? (using unity 5.3.4f1).
     
  33. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    I dont think this plugin is updated to be compatible with WSA apps (remember "direct WP8 target phone is now a WSA SDK) because the code contains only things like

    #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8

    ANy one has deployed it to WSA apps successfully?
     
  34. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    Hi

    I am getting errors:
    EntryPointNotFoundException: _UniWebViewScreenScale

    EntryPointNotFoundException: _UniWebViewChangeInsets

    EntryPointNotFoundException: _UniWebViewHide

    Unity 5.3.4p4 on Mac using Uniwebview 2.7.1 in the Editor (it used to work), upgraded from slightly older version of 2. Also tried deleting all and re-importing uniwebview.

    Any ideas? Thanks

    Screen Shot 2016-05-17 at 15.21.46.png

    Screen Shot 2016-05-17 at 15.22.24.png
     
  35. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    Maybe you need to restart your Unity to let the editor plugin reloaded.
     
  36. sumdog_steve

    sumdog_steve

    Joined:
    Apr 6, 2016
    Posts:
    3
    Has anyone managed to successfully build this plugin to iOS recently?

    I am using the latest version of Unity and this plugin but I get errors when building the xCode project saying there are missing references to:


    "__WebViewPlugin_EvaluateJS", referenced from:

    _WebViewObject__WebViewPlugin_EvaluateJS_m84056263 in Bulk_Assembly-CSharp-firstpass_0.o

    (maybe you meant: _WebViewObject__WebViewPlugin_EvaluateJS_m84056263)"


    Thanks for any help.

    Cheers,

    Steve
     
  37. Wentao

    Wentao

    Joined:
    Mar 11, 2014
    Posts:
    6
    hi, onevcat:
    i've put uniwebview component on a UGUI panel, and i'd like to show some other UI elements on top of the uniwebview panel, but seems all other UI elements are blocked by uniwebview (since it's always on top of all other panels).

    so my question is:
    is it possible to show some other ui elements on top of uniwebview panel?
    if so, how could I do it?

    Thanks,
     
  38. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    well Wentao, actually not, because uniwebview are basically "native components" so they run in their "own way" (to say somethin)... so the "unity player" is native and inside of it, runs its own widget system... so when the webview is show for the system running they are only 2 components (I mean the OS doesnt know what you are displaying inside unity).

    Also, I have another question, Im trying to deploy to WSA device (in unity 5 there are no more WP8 support) so I have added some "|| UNITY_WSA" to some #if inside unitwebview code.... but Im stuck because it seems that

    ??? or maybe Im missing something? in the class InterfaceCallback...
     
  39. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    well, I think the source code for windows phone:

    * is not complete because there is no UniWebViewWP.Interface.ICallback
    * it is not updated to target WSA on unity 5
    * on unity 4... and WP8 it is crashing a lot when double taps or more taps than 2, sometimes with scroll and so on.

    onevcat is alive? or we are out of luck?
     
  40. danneskjold

    danneskjold

    Joined:
    Dec 1, 2012
    Posts:
    29
    Hello,

    I am using Uniwebview2 for a application , which is not a game :)
    I need to turn of the immersive mode , I am using unity 5.4
    I have tried screen.fullscreen
    Also tried the immersive mode plugin on github, it works perfectly well if theres no uniwebview in the scene. But if we use uniwebview, the status bar is gone.. Can someone help me with this please?

    regards
    carloz
     
  41. h4ri

    h4ri

    Joined:
    Oct 15, 2016
    Posts:
    4
    Hello!

    Is there a solution for this? I have the same problem.

    The Android version:

    Android.png

    and the iOS:

    iOS.PNG

    They show the same url's content.
     
    Last edited: Nov 30, 2016
  42. miya0326

    miya0326

    Joined:
    Feb 24, 2015
    Posts:
    6
    Hello

    There is a function I want to realize with Unity,
    Is it possible to do the following things?

    Between the header and footer images created on the Unity side
    I want to display WebView.

    For example, I would like to make a screen like the attached image.

    And if possible, you do not want to modify the native code,
    Because it must be maintained every time the OS version goes up.
     

    Attached Files:

  43. onevcat

    onevcat

    Joined:
    Jan 4, 2013
    Posts:
    105
    You could definitely resize a web view by setting the insets property correctly. See the docs for it to know more.
     
  44. miya0326

    miya0326

    Joined:
    Feb 24, 2015
    Posts:
    6
  45. miya0326

    miya0326

    Joined:
    Feb 24, 2015
    Posts:
    6
    Hello

    I am troubled with the behavior of Android's back button.

    If you execute in the following procedure, the page you read last time will be loaded.
    But what can you do to keep the previous page from remaining?

    -------- Procedure --------
    1.webView.Load (url)
    Url is http://www.yahoo.co.jp/
    2.webView.Show
    3. Back button Click
    4.In my processing I try to operate "webView.Hide" with back button.
    5.At this time WebView is hidden
    6.webView.Load (url)
    Url is https://www.google.co.jp
    7.webView.Show
    8. Back button Click
    9.At this time WebView is hidden
    10.After a while the "webView.OnLoadComplete" event has come up
    11.webView.Show url is http://www.yahoo.co.jp/

    -------- What I tried --------
    · I called the CleanCache method before loading, but the result did not change.
     
  46. my_007

    my_007

    Joined:
    Jan 9, 2017
    Posts:
    4
    hello,Upload to google play in the onReceivedSslError () callback using handler.proceed () is unable to pass the audit,what should I do?
     
  47. wikreate

    wikreate

    Joined:
    Apr 28, 2017
    Posts:
    10
    Hello,
    Please i need your help i purchased the uniwebview plugin and i added uniwebview prefab to my scene but nothing appears when playing scene .
    Thanks
     
  48. zkaka

    zkaka

    Joined:
    May 30, 2013
    Posts:
    5
    Hello there,
    I have a problem with uniwebview. It works fine on editor but very slow on mobile to load a web page. I tested webview on my iphone and I was using 3G, it took 5s to load a "Hello World" page. any solutions, please?
     
  49. sandasumit

    sandasumit

    Joined:
    Jan 6, 2018
    Posts:
    1
    Hide() method takes time to close the webview and also freeze the game webview.
    Any alternate solution for this???
     
  50. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    604
    Hello,

    I use UniWebView without a browser toolbar. Since there is no toolbar, user can't close the web view manually.

    I want to add a button into the html and close the webview via javascript triggered by this new button.

    How can I do that?