Manual     Reference     Scripting   
  
Unity Manual > Advanced > Web Player Deployment > Customizing the Unity Web Player's Behavior   

Customizing the Unity Web Player's Behavior

The Unity Web Player allows developers to use a few optional object and embed tag parameters to easily control its behavior in a few ways:

  • disableContextMenu: This parameter controls whether or not the Unity Web Player displays a context menu when the user right- or control-clicks on the content. Setting it to true prevents the context menu from appearing and allows content to utilize right-mouse behavior, the default is false.
  • disableExternalCall: This parameter controls whether or not the Unity Web Player allows content to communicate with browser-based JavaScript. Setting it to true prevents browser communication and so content cannot call or execute JavaScript in the browser, the default is false.
  • disableFullscreen: This parameter controls whether or not the Unity Web Player allows content to be viewed in fullscreen mode. Setting it to true prevents fullscreen viewing and removes the "Go Fullscreen" entry from the context menu, the default is false.

Here is an example set of object and embed tags that limit the behavior of the Unity Web Player, the context menu will not be shown and fullscreen viewing is not allowed:

<object id="UnityObject" classid="clsid:444785F1-DE89-4295-863A-D46C3A781394"
    width="600" height="450"
    codebase="http://webplayer.unity3d.com/download_webplayer/UnityWebPlayer.cab#version=2,0,0,0">
    <param name="src" value="MyDataFile.unity3d" />
    <param name="disableContextMenu" value="true" />
    <embed id="UnityEmbed" src="MyDataFile.unity3d" width="600" height="450"
        type="application/vnd.unity" pluginspage="http://www.unity3d.com/unity-web-player-2.x"
        disableContextMenu="true" />
</object>

In the above example you'll notice that neither disableExternalCall nor disableFullscreen are specified, therefore their default values are used. You'll also notice that disableContextMenu is specified and included in both the object and embed tag blocks. It is important to include all tag parameters in both locations in order to ensure that all users are offered the same functionality regardless of the browser they are using.

Note: developers that modify the default HTML file created by Unity must be sure to make edits in a few locations due to how that HTML file is structured. The first section to modify is the JavaScript block that detects the Unity Web Player, and if found writes out the object and embed tags. The second section to modify is the noscript block at the end in case the page is viewed by a user with JavaScript disabled. Editing both sections, and both the object and embed tags in each section, will ensure that all users, in all browsers will have the same experience.