17 Jul 2013


Have you ever wanted to apply a full-screen effect to your GUI without having to completely restructuring the way you set up your OnGUI structure? Or how about rendering text and GUI controls onto in-scene virtual screens and objects? Yea me too.

So a couple of years ago I did a friday project investigating the possibility of a setup like this. What I wanted was a Doom 3 – style in-game numpad, responding to mouse clicks. Unfortunately I couldn’t get there 100% and in a nice and straight-forward way, so I abandoned it with no further time spent.

The specific problem was that while I could get my GUI to render to the object just fine, the GUI system had no way of injecting events or modifying existing ones. This meant that if I wanted GUI to respond to events, I would have to bypass the GUI event system and effectively rewrite the basic GUI controls. That failed my “nice and straight-forward” requirement.

However a while later, I came across a similar need: I had a project where the screen was warped slightly fish-eye, to give an impression of an old-school CRT display. It looked great, except the GUI was just rendered on top of everything – as per usual – with no warping. Since the GUI was non-interactive, there was no down-side to using the approach I had come up with before to include the GUI in the full-screen effect rendering.

It was a snap to apply, I had no required changes to my general OnGUI structure and the result looked great. This setup also came in handy when I was working with the Oculus Rift – rendering the GUI on a plane, rendered always on top, in front of the Oculus cameras.

So what is the idea then? Well it is quite straight forward: OnGUI is invoked multiple times each frame (once per event) – at least twice – unless layouting has been disabled on the MonoBehaviour. The last event of the frame is the repaint event. In this, all resolved controls render to the active context. Which fortunately can be set by render textures.

The trick therefore becomes:

Remember that this is not immediately useful if you need interactive GUI as this would require work to handle input gathered from the regular UnityEngine.Input API. Nonetheless it will give you for instance a scrolling screen of text on an in-game monitor.

I hope you find it useful!

New Gear
Unity, iOS, TeamCity, AppCenter
RAID0 NVMe on Ubuntu
A Change of Gears
Unity Protocol Buffers
Behave 2.7
Behave 2.6
Trusted Gear
Mad Mash Versioning
Behave 2.5
Behave 2.4
The Engine Wars: Numbers
GDC 14: The Quest For Fun
Moving in Unity
Behave 2.3
Unity and .net assemblies
Behave 2.2
Behave 2.1
Behave 2.0
Unity Hacks: Dual sticks
Unity Hacks: Cameras
Unity Hacks: Touch gestures
Unite 13 video "Unity Hacks" available
The implicit local network interface
Talks and progress
Five years of Unity expertise looking for contracts
Automagic Unity Android Java gadget OF DOOM!
Invading Planet from your couch
Mountain Lion and laggy bluetooth and duct-tape
Unite 12 video and new videos section available
Asia Bootcamp videos now available
Path is now MIT licensed
Behave 1.4 released
So I've been a bit busy lately
Behave 1.3 released
IGDA Unity SIG slides
Second Unity IGDA SIG this evening: Scene construction and AI
First IGDA Unity SIG this evening
Alternative licensing available
Pathfinding in two lines
Path 2 released
Assembling and assimilating
Path 2 intro screencast
Path 2 beta release for GGJ
AIgameDev master class video now online
Expanding beta
Behave AIgameDev master class public stream
Behave master class on open AIgameDev stream tomorrow
Interview with AIGameDev
New video: From tree to code
Issue tracking on github Behave release project
IT University Copenhagen Unity course completed
IT University Copenhagen Unity course files Thursday
CPH IT University Unity course files
Behave 1.2 released
Video: Behave - starting from scratch
Behave runtime documentation updated
Behave 1.1 released
FAFF cleanup: Sketch
Building a menu of delegates and enums
Pick me! Pick me!
Optimising coroutine yielding in C#
Downloading the hydra
New license of Path: GPL
GUI drag-drop
Logging an entire GameObject
I bet you can't type an A!
Where did that component go?
New and improved: Behave 1.0 released
Behave 0.3b and unity 2.5
Behave 0.3b hotfix
Path tutorial video available
Path 1.0 launched!
Continued community tutorials
Community tutorial
New tutorial
First tutorial available
Behave 0.3b
unite '08 open-mic session
Behave 0.2b
Behave 0.1b
Behave pre-release
Path beta 0.3b
Path beta 0.2b
Path beta 0.1b
Path pre-release