// Use this for initialization void Start() { // Next, generate a new UI: FlatWorldUI ui = new FlatWorldUI("BillboardContent"); // It's representing a TV, so lets use some standard TV screen dimensions: ui.SetDimensions(800, 600); // As this example only uses a WorldUI, we'll set the filter mode to bilinear so it looks smoother. ui.TextFilterMode = FilterMode.Bilinear; // Give it some content: if (HtmlFile != null) { ui.document.innerHTML = HtmlFile.text; } if (InputEnabled) { // World UI's should accept input: UI.WorldInputMode = InputMode.Screen; } // Grab the texture: Texture texture = ui.Texture; // Assign it to the parents material: Material material = gameObject.GetComponent <MeshRenderer>().sharedMaterial; // Apply it: material.mainTexture = texture; }
/// <summary>Updates the FlatWorldUI so it builds the mesh for this element.</summary> private void UpdateRenderer(LayoutBox box, float width, float height) { // - Set w/h to width and height: int w = (int)width; int h = (int)height; // Resize the renderer (which will emit a changed image event): Renderer.SetDimensions(w, h); // Temporarily set the positioning of 'box' such that it's at the origin: int _pos = box.PositionMode; BoxStyle _position = box.Position; // Clear: box.Position = new BoxStyle(0f, float.MaxValue, float.MaxValue, 0f); box.PositionMode = PositionMode.Fixed; // Put the RenderData in the render only queue of *Renderer* and ask it to layout now: RenderableData _next = RenderData.Next; UpdateMode _mode = RenderData.NextUpdateMode; RenderableData _ancestor = RenderData.Ancestor; // Clear: RenderData.Next = null; RenderData.NextUpdateMode = UpdateMode.Render; RenderData.Ancestor = null; // Queue: Renderer.Renderer.StylesToUpdate = RenderData; Renderer.Renderer.HighestUpdateMode = UpdateMode.Render; // Draw now! Renderer.Renderer.Update(); // Restore (box): box.Position = _position; box.PositionMode = _pos; // Restore (queue): RenderData.Next = _next; RenderData.NextUpdateMode = _mode; RenderData.Ancestor = _ancestor; }
/// <summary>Updates the FlatWorldUI so it builds the mesh for this element.</summary> private void UpdateRenderer(LayoutBox box, float width, float height) { // - Set w/h to width and height: int w = (int)width; int h = (int)height; if (Renderer.SetDimensions(w, h)) { // Output texture changed. if (Filter == null) { // Update output: Output = Renderer.Texture; if (Material != null) { // Hook up the output: Material.SetTexture("_MainTex", Output); } } else { Filter.Set("source0", Renderer.Texture); // Output will be updated shortly. // Always mark as changed: Filter.Changed = true; } } // Redraw: if (Filter != null) { if (FilterDrawInfo != null) { FilterDrawInfo.SetSize(w, h); } // Draw now: Output = Filter.Draw(FilterDrawInfo); if (Material != null) { // Hook up the output: Material.SetTexture("_MainTex", Output); } } // Temporarily set the positioning of box such that it's at the origin: float _x = box.X; float _y = box.Y; float _pX = box.ParentOffsetLeft; float _pY = box.ParentOffsetTop; int _pos = box.PositionMode; // Clear: box.X = -box.Border.Left; box.Y = -box.Border.Top; box.ParentOffsetTop = box.X; box.ParentOffsetLeft = box.Y; box.PositionMode = PositionMode.Fixed; // Put the RenderData in the render only queue of *Renderer* and ask it to layout now: RenderableData _next = RenderData.Next; UpdateMode _mode = RenderData.NextUpdateMode; // Clear: RenderData.Next = null; RenderData.NextUpdateMode = UpdateMode.Render; // Queue: Renderer.Renderer.StylesToUpdate = RenderData; // Draw now! Renderer.Renderer.Update(); // Restore (box): box.X = _x; box.Y = _y; box.ParentOffsetTop = _pX; box.ParentOffsetLeft = _pY; box.PositionMode = _pos; // Restore (queue): RenderData.Next = _next; RenderData.NextUpdateMode = _mode; }