- Home /
Is it possible to render a GUI.TextArea into a Texture ?
Hi, Is it possible to render a GUI.TextArea into a Texture ?
Although I can render the GUI Text and GUI Texture GameObjects easily into a Camera Texture Target, I don't find a way to do it with GUI.skin objects created in C#.
My goal is to create at run time textures of word wrapped text.
using UnityEngine; using System.Collections;
public class DetailedViewLayoutTest : MonoBehaviour {
private string myString;
void Start ()
{
myString = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum";
}
public GUISkin gSkin;
void OnGUI ()
{
if (gSkin)
GUI.skin = gSkin;
else
Debug.Log ("ConfigureMenuGUI : GUI skin object missing!");
GUI.TextArea(new Rect(0, 0,200, 400),myString,"Content Text");
}
}</code></pre>
Thanks for your help !
Answer by qJake · Jun 03, 2010 at 05:04 PM
GUISkins and GUI.Labels support word wrapping automatically, so if that's what you're after, just use a GUI.Label. Don't use TextArea unless you want the text to be editable, and even then, you aren't using GUI.TextArea correctly, you need to use it like this:
myString = GUI.TextArea(new Rect(0, 0, 200, 400), myString, "Content Text");
Thanks for this good advice. I guess my question remains and is now:
" Is it possible to render a GUI.Label into a Texture ?"
Your answer
![](https://koobas.hobune.stream/wayback/20220613045931im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it possible to render a GUI.Label into a Texture ? 1 Answer
EditorGUILayout.TextArea Wrap 2 Answers
Text To Texture/Image 1 Answer
Ways to blit into a texture? (iOS compatible) 2 Answers
Problem with minimap 0 Answers