- Home /
Implementing a scrollable textarea without using UnityGUI
Hey all,
I'm partway through the process of implementing my GUI using Meshes and 3dText, but have hit a major block. I'm completely stumped with how to do a scrollable text area, as I can't see a way of clipping text depending on where the view is looking without using RenderToTexture, which is not an option as I'm using the free version.
This is what I want to be able to acheive:
Thanks in advance,
Wibbs
Answer by Bunny83 · Apr 07, 2011 at 01:24 PM
Well, just write a clipping shader ;) I guess I would clip after the projection in homogeneous clip space.
You can of course use a second camera (yes, it works in free). You can alter the normalized viewport rect to set the desired area on screen. Let the second camera just draw your text meshes (culling mask) and you're done ;)
Thanks for the quick answer. I'd thought of using different cameras already, but wondered if there was a less 'hacky' way of doing it.
Shaders sound kind of complicated, but that's probably because I've never been near one before. Looks like I have some reading to do :D
Well, a second camera isn't really "hacky" :D. A camera is just another view and projection matrix, nothing more. Putting things on different layers that you can selectively render your stuff is also a common and intended function. But it's up to you ;) Good luck.
Bunny83, Wibbs 1, Can you guys give me a hand on this?, How Can I use a second camera to render to a texture(im using Unity indie). Or do you have any example on how to use a clipping shader on this matter?, Please..im running out of time,
You can not (efficiently) render to a texture in the indy version. What i have suggested is to use a second camera to directly render the textmesh onto the screen.
Just add a new camera and define a seperate layer for your GUI. Put the GUIText or Text$$anonymous$$esh object on the GUI layer, exclude your GUI layer from your main camera's layermask and set the layermask of your second camera to only render your GUI layer. Now you can simply change the normalized viewport of your second camera to specify the rect on the screen. When you move the text or the camera the text is scrolling but clipped by the cameras border.
I see, thank you for your comment, :D. Im using Vuforia SD$$anonymous$$ for a project. So I need to clip a Text$$anonymous$$Esh which is on a 3D surface...so I can scroll text and it can be seen only inside.., I believe I need a clipping shader, but I dont know yet how to do one, or where to get one.