The Unity Web game is run in the browser's Unitywebplayer plugin, the mode of operation is webplayer.unity3d+html
UnityObject2 's Initplugin function is called in a Web page that embeds Unitywebplayer, and Webplayer.unity3d is passed in as a parameter to initialize the running environment of the unity Web game.
Note: game DLLs and other managed DLLs will be written to the Webplayer.unity3d file when building the Web version
unityobject2.js ( other links 1 other Links 2)
A function that detects the unity Web player plug-in, initializes its installation, and embeds unity content. You can deploy the Unityobject2.js file to a network server with an HTML file.
However, it is best to load directly from the Unity server at the address: http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js or https:// Ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/unityobject2.js (to get HTTPS support).
This way, you will always use the latest version of UnityObject2. and the Unityobject2.js file hosted on the Unity server is compressed, making it smaller and saving traffic.
Unityobject2.js source files can be found in the Data\resources folder in the Windows System Unity Editor and in the Contents/resources folder in Mac OS x.
Browser support Scenarios
As the major browser vendors began to gradually do not support browser plug-ins, Unity5.4 and later versions, Untiywebplayer was removed, only provide WEBGL export to support web games. unitywebplayer Road Map
Browsers that support Unitywebplayer are:
Windows platform Browser- IE Series (note: The latest is IE11. Win10 started using edge as the default browser, andedge does not support plugins. In addition, in order to access the Web site that needs plugins, WIN10 also provides IE browser)
Mac OS X Platform browser- Safari
Cross-platform browser-versions prior to Chrome 45, versions prior toFirefox 52.0, and versions prior toOpera 37
Domestic browser-such as: QQ browser, 360 browser, etc. generally have 2 modes: Compatibility Mode (IE) and fast mode (chrome core)
Although the integrated Chrome kernel version is more than 45, these homegrown browsers will typically modify the integrated chrome kernel to support the operation of the Npapi plugin.
Note 1: In addition to IE is the use of ActiveX plug-ins, other browsers are NPAPI plug-ins
NOTE 2: The Chrome 42 version starts by default to disable the NPAPI plugin, but allows the user to turn it on manually, and by the 45 version it is forced to disable
Note 3: Firefox version 52.0 forces all NPAPI plugins except flash to be banned
Unitywebplayer Plug-in
:https://unity3d.com/cn/webplayer/
Https://unity3d.com/cn/webplayer/setup
Http://webplayer.unity3d.com/download_webplayer-3.x/UnityWebPlayer.exe
Http://webplayer.unity3d.com/download_webplayer-3.x/UnityWebPlayerFull.exe
If you need a specific version of Untiywebplayer, you can install the corresponding Unity Editor and have the corresponding UnityWebPlayer.exe installation file in the editor directory
Form: D:\Program Files (x86) \unity\editor\unitywebplayer.exe
Directory key value record is the installation directory for Unitywebplayer:%homepath%\appdata\locallow\unity\webplayer
un. Directory key value records are the directories where the Unitywebplayer uninstaller Uninstall.exe
Query the information and operation status of Unitywebplayer plug-in in IE:
Win7 64bit Internet Explorer9: Main Menu-Manage add-ons
To uninstall the Unitywebplayer plugin from the control Panel:
post-Installation Unitywebplayer directory structure --Installed in%homepath%\appdata\locallow\unity\webplayer
Player is the Unity Runtime framework that provides a basic environment for game operation
The mono virtual machine is responsible for interpreting the execution of game script logic
Loader for browser plug-ins: ie under the ActiveX control (OCX), other browsers for Npapi Dll,mac as. plugin files
DLLs in Player\beta-4.63.x.x\data\lib and Mono\beta-4.63.x.x\data\lib are managed DLLs
The following is the URL link (captured using Finddler ) that was accessed during Unitywebplayer initialization
Http://10.123.102.142/resources/Client/junhongwang/NZWebTGame.unity3d
http://autoupdate-revision.unity3d.com/revisions.plist?content=http%3a%2f%2f10.123.102.142%2fresources% 2fclient%2fjunhongwang%2fnzwebtgame.unity3d&page=http%3a%2f%2f10.123.102.142%2fresources%2fclient% 2fjunhongwang%2fnzwebtgame_innernew.html&runtime=3.x.x&
Http://webplayer.unity3d.com//Channels/a7fe7b7f3d1f/UnityPlayer3.x.x-win32.zip //will be downloaded to%homepath%\appdata\ Local\microsoft\windows\temporary Internet Files\content.ie5\cofolvja\unityplayer3.x.x-win32.zip
Http://webplayer.unity3d.com//Channels/a7fe7b7f3d1f/Mono3.x.x-win32.zip //will be downloaded to%homepath%\appdata\local\ Microsoft\windows\temporary Internet Files\content.ie5\c3aylt70\mono3.x.x-win32.zip
Note: UnityWebPlayer.exe contains only loader directories, UnityBugReporter.exe, and UnityWebPlayerUpdate.exe files
UnityWebPlayerFull.exe contains the mono directory and the player directory in addition to the content contained in UnityWebPlayer.exe
Unitywebplayer plugin is initialized, depending on the runtime version number of the current game, go to the installation directory to find out if the corresponding version of mono and player, if not exist download them
Run-Time temp directory --%temp%\unitywebplayer
+---Unitywebplayer
+---Log
| Log_bb370ff473d10349836025afd6e6808f.txt//log files
| Manager_77b9ab931e2f344884b164d4660a0d19.txt
|
\---Temp
\---bb370ff473d10349836025afd6e6808f//To prevent multiple browser instances from occupying the same DLL, the following 3 DLLs will be copied from the Unitywebplayer installation directory before each instance is run
Mono-1-vc.dll
Webplayer_win.dll
Wrap_oal.dll
IE Temp directory
Reg QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"/V Cache
As: Win7 64bit Internet Explorer9 cache directory
Because of the Unitywebplayer sandbox security restrictions, unity Web games do not have any access to the user's other directories and files in addition to reading the files in the browser cache directory
Development and debugging skills
Print the log in the script to the browser's console window:
"C Onsole.log " " My log message " );
To run the game using development mode :
1. Do not disable the right-click menu in the HTML page
2. Hold down the ALT key and right-click on the Unitywebplayer plugin to pop up the following shortcut menu (a menu item with a release channel will be displayed)
3.%homepath%\appdata\locallow\unity\webplayer\player\beta-4.63.x.x-development version of Unitywebplayer will be downloaded to run the game
The output log will contain stack information
[2017-06-06 11:04:44 416] Publishlog:device info:DeviceId:d8c0a2227ec766787d43edbbba9fbd7a8d687a74 Devicetype:desktop Devicemodel:intel (R) Core (TM) i7-4790 CPU @ 3.60GHz (16313 MB) devicename:nicochen-pc0 operatin Gsystem:windows 7 Service Pack 1 (6.1.7601) 64bit systemmemorysize:16313 Graphicsdevicename:nvidia G eFORCE GTX 660 Graphicsdeviceversion:direct3d 9.0c [Nvd3dum.dll 9.18.13.3788] Graphicsmemorysize:1 989 graphicsshaderlevel:30 Screen size:1440x900 dpi:96 Processortype:intel (R) Core (TM) i7-4790 CPU @ 3.60GHz processorcorecount:8unityengine.debug:internal_log (Int32, String, Object) Unity Engine.Debug:Log (Object) WNEngine.Logger:GeneralLog (Elogtype, String, object[]) WNEngine.Logger:PublishLog (String, Object[]) WNEngine.Logger:PrintIdentifyLog () WNEngine.Logger:Init () WNGameBase.GameFramework:Awake () (filename:c:/ Buildslave/unity/bUild/artifacts/webplayergenerated/unityenginedebug.cpp line:56)
Attach Debugging Games
1. Need to open the debug switch in the HTML page
2. Open the Game Project project, "Debug"--"Attach Unity Debugger"
Unitywebplayer Security Sandbox (safety sandbox)
By Unitywebplayer Sandbox restrictions, Untiywebplayer accesses the method in the native module and throws the following exception:
Methodaccessexception:attempt to access a private/protected method failed.
If you want to use the functions in the Natvie module in Untiywebplayer, you can do this by indirect circumvention:
(1) Write a browser plugin, call the native module in the plugin
(2) in Untiywebplayer, the JS function is called by Externalcall, and the corresponding function in the plugin is called in the JS function, and finally the call to the native module is realized.
Reference
u3d-page Tour-detection mechanism-webplayer-debugging method
Unity Web Game features analysis