In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to embed the web plug-in UniWebView in Unity. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Common implementation methods of embedded web pages in Unity:
1. UnityWebCore only supports windows.
2. Unity-Webview supports Android,IOS.
3. UniWebView supports mac os,Android,IOS,WP8 (after 2.0)
Second, UniWebView calls the corresponding WebView components to display web pages according to the mobile platform, which supports interaction with javascript, but does not support display on windows and editor.
1. Download and import unitypackage
Http://uniwebview.onevcat.com/
2. Set up Webview, load and display web pages
/ / Find the UniWebView component on the gameObject.// It is supposed you have already dragged this script to the same gameObject which UniWebView on.// Or you will get a null exception: (_ webView = GetComponent (); / / Listen to some event of UniWebView_webView.OnLoadComplete + = OnLoadComplete;_webView.OnReceivedMessage + = OnReceivedMessage;_webView.OnEvalJavaScriptFinished + = OnEvalJavaScriptFinished;// Almost full screen but 5 points gap in each edge._webView.insets = new UniWebViewEdgeInsets / / Set a url string to load_webView.url = "http://uniwebview.onevcat.com/demo/index.html";// Tell the web view begin to load the url just set._webView.Load (); / / Then wait for the OnLoadComplete event /... / / The listening method of OnLoadComplete method.void OnLoadComplete (UniWebView webView, bool success, string errorMessage) {if (success) {/ / Great, everything goes well. Show the web view now. WebView.Show ();} else {/ / Oops, something wrong. Debug.LogError ("Something wrong in web view loading:" + errorMessage);}}
3. Web address resolution
Uniwebview://move?direction=up&distance=1 will be parsed into
Path = "move" args = {direction = "up", distance = "1"}
4. Monitor messages
Void OnReceivedMessage (UniWebView webView, UniWebViewMessage message) {Debug.Log (message.rawMessage); if (string.Equals (message.path, "move") {/ / It is time to move! / / In this example: / / message.args ["direction"] = "up" / / message.args ["distance"] = "1"}} Thank you for reading! This is the end of the article on "how to embed the web plug-in UniWebView in Unity". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.