- Home /
GUI.Label or any text with GUIStyle as Texture
Good day
I recently started developing an own android-app. Around half of the application will be 2D (with dynamic contents), I started looking into making the required GUI-elements. Since Unity has (as far as I've found out) no implementation of a slide(show), I had to make my own. Considering that elements in this slide can become only half visible upon reaching the border of the viewable area of the slide, I converted all GUI-elements into textures, to use GUI.DrawTexture(), which has as one parameter the area of the texture to draw.
Unfortunately, I've found no function of unity to convert a GUI.Label (or any GUIStyled text) into a Texture. I tried to write a function, that adjusts the text of the GUI.Label to the visible area (using GUIStyle.CalcSize(GUIContent)). However, this algorithm decreased performance by far too much, so I discarded it.
My question is, if there is any other way to either convert a GUI.Label (or a text with GUIStyle) into a Texture, or to only draw a specified part of the GUI.Label/Any other GUIStyled text on GUI. Any help would be appreciated.
Answer by HappyMoo · Jan 02, 2014 at 04:36 PM
You want masks... which are not available for the current gui system. You could use multiple cams and this dept mask shader to hide what is outside: http://wiki.unity3d.com/index.php?title=DepthMask
Also check the discussion here: http://forum.unity3d.com/threads/2730-Stencil-buffer?p=20381#post20381