HtmlTexturePlugin

= Author info =

Created by Rob Terrell of Stinkbot LLC. You can contact him at robterrell@gmail.com.

= What it does =

The htmlTexture plugin renders web content into a texture you can apply to any material. Interaction with the web page is possible through simulated mouse clicks and javascript. Any web content the underlying browser can display (including Flash, Shockwave, PDF, Quicktime movies, etc.) is supported.

The most recent version, 0.5 (25 Jan 2008), supports multiple textures and URLs. You can create as many HTML textures as you need. The framerate, even with multiple Flash animations, is quite good.

Limitations
The texture appears backwards in Unity, so you need to apply a placement transform of -1.0 in the X dimension. Textures dimensions currently must be a power of two (i.e. 256, 512, 1024).

= How to use =

Like other texture plugins, your code needs to create a new bitmap at the start, then call htmlTexture_start with the ID of that texture. You then update the texture's pixel data every so often -- typically every Update or FixedUpdate. The sample below is C#:

Attach the above script to a game object, and when you Play the scene, its texture will be the current Google home page.

Please note that, as in the Quicktime plugin, the texture is reversed left-to-right when applied to an object. You can flip the texture's appearance on the object by applying a placement size transform of {-1,0} in the object editor.

Simulated mouse events
The htmlTexture plugin can simulate mouse events in the offscreen web view, allowing for basic web browsing (i.e. clicking links).

You can cast a ray from the camera to the location of a mouse click to find the texture coordinate of a click. You can then pass that to the plugin, but since the texture appears backwards, you need to do a little subtraction first.

The object this is attached to needs to have a mesh collider for this to work.

= Download =

You can download the current version of the plugin from here. Currently, the plugin is a Mac-only universal binary.

= Copyright =

This plugin is Copyright 2007 Stinkbot LLC. Please check with us before including it in release builds of your projects.

= Version history =


 * 0.1 First working version
 * 0.2 Second working version
 * 0.3 Added mousedown, mouseup, mousemoved, goBack, goForward
 * 0.4 Universal binary
 * 0.5 Added support for multiple textures, getURL, and returning a result from javascript calls.

= To do =

Support an arbitrary number of textures and webviews: DONE. Windows version: in progress.

= Interface Declaration =