Search Unity

[DISCONTINUED] uWebKit - Chromium WebView for Unity 5

Discussion in 'Assets and Asset Store' started by uWebKit.com, Aug 1, 2013.

  1. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @jwhite19: Hello, you can view the C# API and download the unity package, which includes getting started and API PDF files from the GitHub site: https://github.com/uWebKit/uWebKit

    The trial allows you to select either standard or pro features. We can also extend the trial period if you need more time.

    ~Josh
    http://www.uwebkit.com
     
  2. darynlim

    darynlim

    Joined:
    Oct 25, 2013
    Posts:
    6
    Hi, I'm currently using uWebkit to built a prototype for my company. I encounter a problem which I can't solve. I'm using zoomdata that connects to internal and external data sources to compute it into a d3chart. I wanted to display it on Unity using Webkit however when it comes to loading the d3chart the connection is lost and unable to display the chart. Kindly advise.
     
  3. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    Hello,

    I am able to connect to the Live Demos on the zoomdata website with updates working. Do their live demos work for you?

    If you aren't using uWebKit 1.5, you might want to try upgrading. The package is available on the GitHub site: https://www.github.com/uWebKit/uWebKit

    Cheers,
    ~Josh
    http://www.uWebKit.com
     
  4. darynlim

    darynlim

    Joined:
    Oct 25, 2013
    Posts:
    6
    Hi Josh,

    Their live demo doesnt work for me. I'm using uWebkit 1.5.
    $Capture1.PNG $Capture2.PNG

    Regards,
    Daryn
     
    Last edited: Nov 21, 2013
  5. Jahodo

    Jahodo

    Joined:
    Nov 21, 2013
    Posts:
    2
    I have tried using multiple UWKViews in the same scene, but I can only interact with one of them (scrolling, clicking links). Isn't it possible to interact with multiple views?

    Regards,
    /Jan
     
  6. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
  7. Jahodo

    Jahodo

    Joined:
    Nov 21, 2013
    Posts:
    2
    Thanks, I had tried BringToFront(), but was doing it wrong.
    /Jan
     
  8. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi,

    I just started playing with the uWebKit standard trial version. I can load a web page using the WebGUI script. There we have to mention a width and height to the view. In my prototype I need the web page to be automatically re sizing according to the window's size(it's a unity standalone app). Currently since we specify a width/height, it always remain that size. I would like to know how to do that.

    Also I have another question. In our app there will be some screens where right half of the UI is Html and left half showing a 3D model. This 3D model can change when we click or button on the html or something similar. So I want to know how I can call the unity c# scripts on from my web page. For e.g. when a particular button is clicked I need to pass the information about that to the Unity so we can load the correct model on the left side. Please let me know how to do that.


    Thanks.
     
    Last edited: Nov 22, 2013
  9. darynlim

    darynlim

    Joined:
    Oct 25, 2013
    Posts:
    6
    Hi Josh,

    Yup I managed to displayed the chart demo out from the website however when I downloaded their server to display out the data I have on the 3dchart, It shows connection lost in the browser for Unity. Really appreciated your help.

    Regards,
    Daryn
     
  10. mysterben

    mysterben

    Joined:
    Jun 19, 2012
    Posts:
    7
    Hi there, I'd like to have a play around with uWebKit on iOS using a relatively new MacBook, however I see that you don't support 64bit Macs yet. Just wondering when you are planning to add it?
     
  11. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @mysterben: uWebKit runs on 64 bit macs (all macs are 64 bit now), the Unity Editor and default deployment are 32 bit, so we need to support 32 bit for compatibility. It should work fine on your Mac.

    @darynlim: Are you using file:// to access the server, there can be security limitations when using file:// protocol. Have you tried accessing the server with Chrome or Safari locally?

    @madhur: You can get the ContentWidth and ContentHeight of the web content once the page is loaded: https://github.com/uWebKit/uWebKit/blob/UWEBKIT-15b/uWebKit/Assets/uWebKit/UWKView.cs#L275 and here is an example of interacting with JS/C# on the page, you can try this out in the example browser: https://github.com/uWebKit/uWebKit/...tExamples/Scripts/WebBrowser/UnityInfoPage.cs

    ~Josh
    http://www.uWebKit.com
     
  12. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Thanks. I was able to call the CS from JS by looking at that example.
    I have one other question. I call the CS side from JS by calling Unity.invoke... How can I return a value from this. ie how to read some values from c# side to JS side.?
    In the C# I modified the void method to return string and Unity gives this error
    error CS0407: A method or delegate `string WebGUI.OnSayHello(object, UWK.BridgeEventArgs)' return type does not match delegate `void UWK.BridgeEventHandler(object, UWK.BridgeEventArgs)' return type

    Also is it possible to change some values like X, Y values of the WebGUI at run time(inside the c# method which get called from the JS side, since it's a static method). My first 2 pages needs to run on full screen at 0,0. Then third page(ie. on some button click at second page) I need to show at 500,0 in order to have free space on left side to show he 3D models. Would like to know how to do that.

    Thanks
     
    Last edited: Nov 25, 2013
  13. darynlim

    darynlim

    Joined:
    Oct 25, 2013
    Posts:
    6
    Hi Josh
    I tried accessing through chrome with https://localhost:8443/zoomdata doesn't have any problem but through the uwebkit I'm experiencing some problem regarding the d3 chart. Everything can be displayed except the d3 chart and the connection lost problem occur again.
     
  14. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi Josh, there seems to be a considerable lag when calling a c# method from javascript in the html. On a button click I call the C# method and print a log there. After the button click I have to wait several seconds to get the message get printed. Would like to know the reason for the lag.
    thanks
     
    Last edited: Nov 26, 2013
  15. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @darynlim: I am not sure what the issue is here and why it works with zoom data's live demo, but not locally, can you hose on http protocol instead of https? What protocol is zoom data using to transfer its data?

    @madhur: This is strange there should be close to zero lag, does the example browser "Unity Info Page" tab exhibit this behavior when you click the button embedded in the page?

    ~Josh
    http://www.uWebKit.com
     
  16. darynlim

    darynlim

    Joined:
    Oct 25, 2013
    Posts:
    6
    Hi Josh, the zoomdata uses a server running from vmware and I cant hose on http protocol only https. This is how zoomdata transfer its data. $zoomdata.png

    Regards,
    Daryn
     
  17. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi Josh,

    The example seems ok. (There all the html and JS part also inside the c# script. In my case the js functions are inside the html which hosted somewhere else)
    In the c# script when I put the Bridge.BindCallback ("Unity", "SayHello", OnSayHello); inside the Start() method, Unity crashses. So I added it inside a Update method and also tried inside OnGUI (which is not a good way to do) and tested. Then it work without crashing. But its very slow.

    Now I added another c# script and called setProp method from the Start() there and inside the setProp() method in the other c# script I added Bridge.BindCallback. Now the speed seems ok.

    Any idea why I can't put Bridge.BindCallback inside the Start() method?

    I would like to know how to return a value from OnSayHello() method to the javascript side.
    In the C# I modified the void method to return string and Unity gives this error
    error CS0407: A method or delegate `string WebGUI.OnSayHello(object, UWK.BridgeEventArgs)' return type does not match delegate `void UWK.BridgeEventHandler(object, UWK.BridgeEventArgs)' return type


    Thanks
     
  18. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    I'm testing a trial version and this particular build crashes all the time.
    https://dl.dropboxusercontent.com/u/3601116/uwebkit_crash.zip

    Looking at output_log.txt there seems to be a JS error which gets spamed.

    What should I do in this case?
    Thanks.
     
  19. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Questions:

    1. Is it possible to scale a loaded page?
    I mean like in chrome you can press ctrl+"+" and increase font.
    The page renders too small. Is there a way to do this?

    2. What are the restrictions of trial version except 7 days work time?
     
  20. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @valyard: If you disable the Javascript error spam does the issue resolve, you can do this by modifying the config: https://github.com/uWebKit/uWebKit/blob/UWEBKIT-15b/uWebKit/Assets/uWebKit/UWKConfig.cs#L15, I have filed a ticket for adding zoom support surprisingly this is the first it has been asked about, there are no restrictions on the trial version

    @madhur: It sounds like you may be adding the binding per frame, you should try adding the binding once the view has been created in the view created delegate. You should be able to add a bridge binding in Start, however I am thinking there is an issue with the order here as the web core probably isn't initialized. So, if you can add the binding in the ViewCreated delete, that should work. You can evaluate a JS function on page from C# with a "return" value from your bridge callback.

    ~Josh
    http://www.uWebKit.com
     
  21. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Josh,
    Do you mean to add a method like this in my WebGUI c# script? But it never get called
    Code (csharp):
    1. void ViewCreatedDelegate(UWKView view) {
    2.        
    3.         Debug.Log("============ViewCreated==================");
    4.     }
    Regarding the JS return I'm not clear what you mean by " You can evaluate a JS function on page from C# with a "return" value from your bridge callback." When I try below it gives an error as Bridge.BindCallback is void.

    Code (csharp):
    1. public string setProp() {
    2.        
    3.         string ret = Bridge.BindCallback ("Unity", "SayHello", OnSayHello);
    4.         return ret;
    5.        
    6.     }
    7.  
    8.    
    9.     public string OnSayHello (object sender, BridgeEventArgs args)
    10.     {
    11.        
    12.         Debug.Log("============OnSayHello==================");
    13.         string step = args.Args[1];
    14.         //WebGUI aa = new WebGUI();
    15.         LoadModels(step);
    16.        
    17.         return "mytestreturn";
    18.        
    19.     }
    And when write like this it gives the error A method or delegate `string MyWebGUI.OnSayHello(object, UWK.BridgeEventArgs)' return type does not match delegate `void UWK.BridgeEventHandler(object, UWK.BridgeEventArgs)' return type

    Code (csharp):
    1.     public void setProp() {
    2.        
    3.         Bridge.BindCallback ("Unity", "SayHello", OnSayHello);
    4.        
    5.        
    6.     }
    7.    
    8.     public string OnSayHello (object sender, BridgeEventArgs args)
    9.     {
    10.        
    11.         Debug.Log("============OnSayHello==================");
    12.         string step = args.Args[1];
    13.         //WebGUI aa = new WebGUI();
    14.         LoadModels(step);
    15.        
    16.         return "mytestreturn";
    17.        
    18.     }
     
  22. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @madhur: You need to add the method to the ViewCreated delegate in order for it to be called, for example, https://github.com/uWebKit/uWebKit/...Examples/Scripts/WebTexture/WebTexture.cs#L45, instead of chaining C# and Javascript function calls, which would quickly get unwieldy, you can evaluate Javascript on the page with parameters inside your callback, you do this with the view.EvaluateJavascript(string script); method (which itself can get a string return value back). So you would call your Javascript method with your return value.

    ~Josh
    http://www.uWebKit.com
     
  23. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Thanks Josh I got the ViewCreated part working.

    But I'm still not clear about the returning value from c#.
    My requirement is when I click a button on the html it calls js function and then it calls a c# function using Unity.invoke(). I need to return a value from this c# method back to the JS side. I'm not clear how I can do that with view.EvaluateJavascript. Can you please provide an example for this scenario. Sorry for the trouble. What I want is to call the c# from the js not the other way around.

    Thanks.
     
  24. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    "Unfortunately" it seems that Cargocollective fixed or otherwise removed this JS error overnight because I'm not getting it anymore.
    But now the app doesn't crash. I turned off JS errors as you said just in case.

    Also another question popped up: is it possible to hide scrollbars other then in built-in css? or inject css which does it?
     
  25. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Why is uWebKit so slow?
    I'm rendering to a 1024x1024 texture and it scrolls window with like 5 fps on a decent machine.
     
  26. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @madhur: If I understand correctly, It isn't possible to return a C# value when calling C# from JS on the page as this would be a blocking operation. You can call C# from JS on the page, and then in your C# method call EvaluateJavascript with a parameter that is your return value.

    @valyard: What are the computer's specifications? uWebKit should perform quite well. It could be that updating the actual page is slow. Do you observe this behavior in the example browser with the UnityInfo page?

    ~Josh
    http://www.uWebKit.com
     
  27. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    core i7s, 8gb ram
    scrolling a 1024x1024 texture in your example 3d scene is kinda slow, maybe 15 fps... very noticeable lag
    tried some 2048 textures and it was really horrible )8
     
  28. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
  29. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi Josh,

    I have another question.
    In the Unity I need to have a UI look like this, there I need to have 1 div transparent so there we can show our 3D models. Other divs are normal html.
    Is this possible to do with uWebKit. If possible please let me know how to do that. I tried changing the Transparent property, but I'm not sure whether I can use that.

    $htmlsample2.png

    Thanks
     
  30. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @valyard: Do you have multiple 2048x2048 textures? Each of these is 16 megs of texture data that needs to be generated by the web process, marshalled to the Unity process, and uploaded to the GPU. If you are doing this per frame in 3D space, you will also not have the dirty rectangle support which is available in the 2D GUI. This quickly becomes a lot of data transfer.

    @madhur: You will need to use alpha masking, please check out the ExampleAlphaMask.unity scene and see if this will work for you.

    ~Josh
    http://www.uWebkit.com
     
    Last edited: Dec 4, 2013
  31. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Just one texture in 3d. Changed your example to a 2048x2048 texture.
    Do you have a working example in 3d which scrolls smooth? Do dirty rectangles help when scrolling the whole page?
    Otherwise this solution doesn't seem to do what it's advertised )8
     
  32. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Thanks Josh. It helped.

     
  33. ATMEthan

    ATMEthan

    Joined:
    Dec 27, 2012
    Posts:
    54
    Hey,

    I'm using your webviews[UWKCore.CreateView(name, url, width, height)] to display pdfs in an app via a docs.google view like so:

    https://docs.google.com/a/allthings....scala-lang.org/docu/files/ScalaByExample.pdf

    and it works great!

    Except for one part, in the top right corner there is a full screen button of some sort that I need to block input for. I've tried going through the UWKCore and skipping any JS popup commands in the UWKCore.processInbound method but after doing so I lose input on the pdf view and I can't do anything but exit. [There is a 24 pixel border around the pdf view that acts as a back button, so clicking the border closes the pdf view] I tried numerous things like return instantly in CreateJSPopup or CreateViewInternal but I always seem to lose input after a few clicks or right after the first click on the pdf view.

    I was wondering if there is a way to disable JS popups altogether or if maybe I have to do something to fix the input... It seems like something is holding onto the input thus stopping anything else from receiving input but I have no evidence to prove that, just a hunch.

    Any help would be great!!

    Thank you,
    Ethan
     
  34. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
  35. vinusha

    vinusha

    Joined:
    Dec 12, 2013
    Posts:
    1
    Hi,

    I am newbie to uWebKit. I created a web page which is dynamically changing its div positions. For that, I used jquery. All are fine. But I need to load that web page using the WebGUI script. I am using uWebKit standard trial version.

    I am getting this error 'Assets/demo2/js/jquery-2.0.4.js(23,19): BCE0043: Unexpected token:' when I have that jquery-min file locally inside the Unity project. Could you please help me to solve this? For now, I have given the remote url "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" inside the tags <script></script> and removed the jquery-min.js file from the Unity project. For the remote url given as above, it works.

    Thanks.
     
  36. ATMEthan

    ATMEthan

    Joined:
    Dec 27, 2012
    Posts:
    54
    Thanks for the reply Josh,

    I left out an important piece of information... This is an issue for standalone builds, specificity windows 64bit builds. I'm sure its an issue on OSX and Windows 32bit but my target platform for standalone is windows 64bit. [I'm actually not that sure on that, I should double check but regardless I'd imagine it would be a similar implementation]

    For iOS I am able to load the pdf through the streaming assets folder as if it were its own webpage. So, no extra controls are loaded in, but for the standalone build since there is no native pdf viewer I have to load it through google docs. I tried looking into disabling controls through the link[something like &controls=false] but I don't think its possible. I'm going to see if maybe there is another website that can load a given pdf but something tells me I'll have no luck. Please advise on what I can do on standalone and if the solution is different for osx and wins I would greatly appreciate both solutions. :)

    Thank you very much!!!!

    -Ethan
     
  37. yurka

    yurka

    Joined:
    May 5, 2011
    Posts:
    3
    Hi,
    Is there an estimate on when (or if) the zoom feature might be available? It's badly needed. I have content that needs to fit without scrolling, if possible.
    Thanks,
    Yury
     
  38. sveligati

    sveligati

    Joined:
    Oct 25, 2012
    Posts:
    3
    Hi,
    Is there a way to catch and redirect clicked hyperlinks within uWebKit to open with the user's external brower? For example, the user runs our game which displays a news page. The links clicked on the news page do not change the current UWKView URL but instead open in Chrome. Thanks!
    -SV
     
  39. ATMEthan

    ATMEthan

    Joined:
    Dec 27, 2012
    Posts:
    54
    Hey uWebKit Team,

    I have now ran into a new problem for an iOS app. Before this hasn't happened and last time I worked on it was 6 days ago when I left my now second latest post to this thread.

    A little about my app before I get into the problem... I use uWebKit Pro that allows me to use more than 1 web view. So, in the app I have two web views. One web view is linked to 4 buttons that play 4 different videos. Another webview is linked up to a pdf. Both webviews are on screen at the same time. So, if your playing video 1 and hit the pdf button, we make the Video Player Webview load an html page that is the color of the background so it looks inactive. Then the pdf fades in and takes up majority of the whole screen. You can hit a back button that fades the pdf view to 0 transparency and can resume exploring the app. Now this new crash that happens, happens when I try to open up either web view. Once I click a button that is linked to either web view it just crashes. Here is my Xcode log of the crash.

    (Filename: /Applications/buildAgent/work/d3d49558e4d408f4/artifacts/iPhonePlayer-armv7Generated/UnityEngineDebug.cpp Line: 53)

    2013-12-18 17:44:16.607 MCG[1673:907] -[UIWebView name]: unrecognized selector sent to instance 0x2000ba40
    2013-12-18 17:44:16.609 MCG[1673:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWebView name]: unrecognized selector sent to instance 0x2000ba40'
    *** First throw call stack:
    (0x3810d2a3 0x3618a97f 0x38110e07 0x3810f531 0x38066f68 0x3d7a50 0x381109c4 0x38067feb 0x38067b43 0x394bd893 0x3810f61b 0x38066f68 0x381109c4 0x38067feb 0x3355b7bb 0x33598f75 0x380e2683 0x380e1ee9 0x380e0cb7 0x38053ebd 0x38053d49 0x372492eb 0x39d56301 0x45d3c 0x45c18)
    libc++abi.dylib: terminate called throwing an exception

    In regards to this issue, it is still an issue. I tried wrapping the google doc pdf view in my own html page via an <iframe> tag. I used a <div> tag to block out the full screen button. Which worked!!!!... only in the editor :( . The moment I put it on a standalone machine it didn't load anything, the web view just stayed white. And it worked if I just ran it from my Mac computer.

    Any questions or misleading information: please ask and I can clarify ASAP. I watch this thread everyday in hopes of an answer. >.<
     
  40. Dlangar

    Dlangar

    Joined:
    Jan 30, 2013
    Posts:
    1
    Hello WebKit:

    We're noticing AVG and a few other virus detection pieces are picking up UWKProcess.exe and reporting it as a virus. This kills the process, obviously, and prevents the pages from being displayed. Couple of questions. 1 - have you guys seen this, and if so, have any suggestions for a workaround (short of telling our customers to register it themselves with their virus detection, or contacting the virus companies to have it registered with them?) Or have you guys contacted any particular virus detection companies to have UWKProcess.exe registered as safe?

    Second, if the process can't be found, you get the "Did you forget to inject the uWebKit" notfication message. This appears even in our pro, registered version. Is there a way to disable this popup, or to provide an alternative callback that so we can provide our own error recovery?

    Thanks!
     
  41. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hello the UWebKit Team,

    I have an existing website where users create accounts and have their own login username and password. I would like to be able to use the login page from my website inside Unity with the help of UWebKit, can UWebKit help me do this? When my Unity application launches I would like to have an empty scene with a single Web GUI window of the login page from the website. Once the user enters their username and password; if the information is correct the Web GUI window would close and the application would be launched, if not the Web GUI would stay open and not launch the application. What I am most interested in is how UWebKit would be able to detect whether the login information is correct in this situation. Would I need to create for example a "Login Successful" page on the website and in the Unity application check for the specific url of the "Login Successful" page, and only launch the application if the Web GUI's url matches this? Or is there a better way of doing this?
     
  42. awnuxcvbn

    awnuxcvbn

    Joined:
    May 26, 2013
    Posts:
    5
    I know how to load local html,But,I donot know how to load the pictures in html like this <img src="loading.gif" style="margin-top:200px" />
    what should i do?
     
  43. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    @vinusha: Please make sure that Unity isn't doing anything with either the contents of the javascript or the file extension.

    @ATMEthan: This is pretty hard to figure out via the forum. Are you able to perhaps share the project via dropbox?

    @yurka: We plan on putting out a new version with zoom controls next week.

    @sveligati: We will see about squeezing that feature into the next release. It sounds like a great idea

    @Dlangar: We have not seen or had this problem reported before. I am not sure why it would be tripping AVG, maybe because it is a subprocess? You can customize the message you refer to here: https://github.com/uWebKit/uWebKit/blob/UWEBKIT-15b/uWebKit/Assets/uWebKit/UWKCore.cs#L632

    @Hamesh81: Yes, you can do this, please see the Facebook example for an example of handling logins: https://github.com/uWebKit/uWebKit/...KitExamples/Scripts/Facebook/FacebookLogin.cs

    @awnuxcvbn: Are you having an issue with missing images or images in general?

    ~Josh
    http://www.uWebKit.com
     
  44. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
  45. TBH-MITRE

    TBH-MITRE

    Joined:
    Apr 2, 2013
    Posts:
    2
    Hello, UWebKit team:

    I cannot get the horizontal scroll bar to appear when the content is wider than the UWKView width. The vertical scroll bar does appear. I am running on Windows 7. And I have tried varying the heights I pass to CreateView() and DrawGUI() (in case the horizontal scroll bar was not visible), but that didn't work.

    Any suggestions?

    Also, I saw that you will have zoom controls added soon. Do you have an ETA on the new version?
     
  46. uWebKit.com

    uWebKit.com

    Joined:
    Feb 16, 2013
    Posts:
    119
    The first test build of uWebKit 1.5.1 is now available:

    http://www.uwebkit.com/static/downloads/uwebkit/uWebKit_v151.unitypackage

    1.5.1 updates the version of WebKit and supports page zooming via the UWKView.ZoomFactor member (default is 100)

    The latest testing build of uWebKit is always available at the GitHub repo: https://github.com/uWebKit/uWebKit

    There is a known issue with Flash content not loading under OSX. If you need Flash content, please stick with 1.5.0 for now.

    @TBH-MITRE: Can you try loading the page with the browser sample and resize it by dragging the lower right corner of the browser window. Also, you could try using the new ZoomFactor on the view to see if you get the horizontal bar. I can get the horizontal scollbar here, is this only an issue on the page or with other content on the web?

    ~Josh
    http://www.uWebKit.com
     
  47. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I found a way to have SmartRects work with transparent webpages. (for example, game HUDs)

    I thought I would share how I did this, so others can benefit from the speed improvements.

    1) Create a new shader with the following content:

    Code (csharp):
    1.  
    2. Shader "UI/WriteOnce"
    3. {
    4.     Properties { _MainTex ("Texture", any) = "" {} }
    5.  
    6.     SubShader
    7.     {
    8.         Lighting Off
    9.         Blend SrcAlpha OneMinusSrcAlpha
    10.         Cull Off
    11.         Fog { Mode Off }
    12.         ZTest Less
    13.        
    14.         Pass
    15.         {  
    16.             CGPROGRAM
    17.             #pragma vertex vert
    18.             #pragma fragment frag
    19.             #pragma fragmentoption ARB_precision_hint_fastest
    20.  
    21.             #include "UnityCG.cginc"
    22.  
    23.             struct appdata_t
    24.             {
    25.                 float4 vertex : POSITION;
    26.                 fixed4 color : COLOR;
    27.                 float2 texcoord : TEXCOORD0;
    28.             };
    29.  
    30.             struct v2f
    31.             {
    32.                 float4 vertex : POSITION;
    33.                 fixed4 color : COLOR;
    34.                 float2 texcoord : TEXCOORD0;
    35.             };
    36.  
    37.             sampler2D _MainTex;
    38.             uniform float4 _MainTex_ST;
    39.            
    40.             v2f vert (appdata_t v)
    41.             {
    42.                 v2f o;
    43.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    44.                 o.color = v.color;
    45.                 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
    46.                 return o;
    47.             }
    48.  
    49.             fixed4 frag (v2f i) : COLOR
    50.             {
    51.                 return tex2D(_MainTex, i.texcoord) * fixed4(2, 2, 2, 1) * i.color;
    52.             }
    53.             ENDCG
    54.         }
    55.     }
    56.    
    57.     Fallback off
    58. }
    59.  
    2) Replace the 4-parameter DrawGUI method, of the UKView.cs file, with the following:
    Code (csharp):
    1.  
    2.     private Material writeOnceMat;
    3.     /// <summary>
    4.     /// Main 2D drawing method for a UWKView, draws the view at the given X, Y coords with width and height dimensions
    5.     /// </summary>
    6.     public void DrawGUI(int x, int y, int width, int height)
    7.     {      
    8.         if (!valid || !Visible)
    9.             return;
    10.        
    11.         if (width <= 0)
    12.         {
    13.             width = Width;
    14.             height = Height;
    15.         }
    16.        
    17.         #if !UNITY_EDITOR  UNITY_IPHONE
    18.         MobileRect = new Rect (x, y, width, height);
    19.         return;
    20.         #endif
    21.        
    22.         int bw = TSet.BackBuffer.width;
    23.         int bh = TSet.BackBuffer.height;       
    24.         Rect br = new Rect(x, y, bw, bh);
    25.        
    26.         if (!writeOnceMat)
    27.             writeOnceMat = new Material(Shader.Find("UI/WriteOnce"));
    28.        
    29.         // fix gui-showing-up-in-world-space issue
    30.         GL.PushMatrix();
    31.         GL.LoadIdentity();
    32.        
    33.         if (SmartRects)
    34.         {
    35.             for (int i = 0; i < 2; i++)
    36.                 for (int j = 0; j < 2; j++)
    37.             {
    38.                 SubBuffer s = TSet.SubBuffers[i, j];
    39.                 if (!s.Active)
    40.                     continue;
    41.                
    42.                 Rect r = new Rect(x + s.X, y + s.Y, s.Width, s.Height);
    43.                 Graphics.DrawTexture(r, s.Texture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, new Color(.5f, .5f, .5f, _transparency), writeOnceMat);
    44.             }
    45.            
    46.             if (UWKCore.imeEnabled)
    47.                 DrawTextIME(x, y);
    48.         }
    49.         Graphics.DrawTexture(br, TSet.BackBuffer, new Rect(0, 0, 1, 1), 0, 0, 0, 0, new Color(.5f, .5f, .5f, _transparency), writeOnceMat);
    50.        
    51.         // reset fix matrix
    52.         GL.PopMatrix();
    53.     }
    54.  
    3) Find the line below, in the OnWebGUI method of the UKView.cs file:
    Code (csharp):
    1.  
    2. SmartRects = (transparency >= 100.0f  !AlphaMask) ? true : false;
    3.  
    4) Replace the line above, with the line below:
    Code (csharp):
    1.  
    2. SmartRects = true;
    3.  
    Voila. SmartRects now work for transparent webpages, giving you a much faster refresh rate, without the visual glitches that would normally arise.

    How does it work? The WriteOnce shader is special in that it only draws onto each part of the screen once each frame. By having it draw the SmartRect buffers first, it is able to quickly refresh changed areas, while also having the later-called refresh-the-rest-of-the-screen draw-pass keeping those areas from remaining onscreen even when the content has moved away.

    The only drawback I've seen so far is that there is a slight graphical issue when the camera is intersected by a plane--for example, with the camera halfway under the water. In this case, the end of the water surface is slightly visible, through the UI. I don't really know why this happens.

    Other than this, though, I haven't had any issues with it, and have gotten roughly a 50% faster refresh rate for regional UI changes. (such as when dragging dialog boxes, or having tooltips fade in and out)
     
  48. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Is there a way to debug the game in Unity without causing the UWKProcess.exe process to shut down? It makes it difficult to debug the game, as a lot of the game depends on interaction between the C# scripts and the browser-based Javascript.

    There was a similar issue with pausing the game in the Editor, except I fixed it (halfway/with Unity sometimes-crashing) by use of a background thread, which keeps the UWKProcess.exe process alive by sending the "are you unresponsive" polling message every few seconds--I have it set so this thread starts running when the game is paused, and aborts itself when the game resumes. Unfortunately, this doesn't work when the game hits a breakpoint, as this causes the Mono debugger to pause the Unity editor process as a whole.
     
    Last edited: Feb 1, 2014
  49. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi,
    I'm doing the development in a Mac. I created a windows build to run on a windows machine. When I try to inject player. It gives this error. But both Windows and Windows64 folders are there in that path. I tried both Inject Player and Inject Player 64.
    I'm using a licensed version of uWebKit.

    FileNotFoundException: \CODE\ClassRoomApp\UnityWebKitTest\WebKitTest\Asse ts\Editor\uWebKit\Native\Windows64\Plugins\UWKPlug in.dll does not exist
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/File.cs:107)
    uWebKitInjectPlayer.InjectPlayer (System.String path, Boolean display_success, Boolean x64) (at Assets/Editor/uWebKit/uWebKitInjectPlayer.cs:85)
    uWebKitInjectPlayer.InjectPlayer64 () (at Assets/Editor/uWebKit/uWebKitInjectPlayer.cs:51)

    Thanks
     
  50. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    I got that issue fixed using this https://github.com/uWebKit/uWebKit/issues/12

    Now I have another issue.
    I'm testing my app in a 32 inch monitor. When I run my app in pure html version it looks fine. But when I run it using uwebkit as a unity build, the image boxes in my UI are stretched. I expected it to look just like the pure html version. It's not a resolution issue.
    Please have a look at the two screenshots. The first is the html version and second one is the uwebkit version. Any idea why it happens like that?

    Html
    $screenshot3.png

    uwebkit
    $screenshot4.png

    Thanks

     
    Last edited: Jan 29, 2014