Customizing the Unity Web Player's Behavior

Unity Manual > Advanced > Web Player Deployment > 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 of false are used and the content will be allowed to communicate with browser-based JavaScript as well as allow the user to view the content in fullscreen mode if desired.

Note: all optional object and embed tag parameters must appear in both the tag sets in order to function properly in all browsers. Notice that in the example above the optional disableContextMenu parameter is specified as a custom <param ...> tag for use by the object tag as well as through a custom name/value pair directly within the embed tag.