Unity Texture2d



  • 2What it does
  • 3How to use

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

Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers. Texture represent the GPU (graphic card memory) side of a Texture RenderTexture, based on Texture, add the shader/material management Texture2D, based on Texture, add a CPU (processor, ram) side management. It handle the Hard Drive loading/saving of the pnj/jpg/etc.


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).

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.

Unity Texture2d To Sprite

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

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

Unity


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

Unity Texture2d To Image


  • 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.

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

Unity Texture2d Loadimage

Retrieved from 'http://wiki.unity3d.com/index.php?title=HtmlTexturePlugin&oldid=12974'