x


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");

        }

    }

Thanks for your help !

more ▼

asked Jun 03 '10 at 04:04 PM

stephane gravatar image

stephane
51 2 2 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

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");
more ▼

answered Jun 03 '10 at 05:04 PM

qJake gravatar image

qJake
11.6k 43 78 161

Thanks for this good advice. I guess my question remains and is now:

" Is it possible to render a GUI.Label into a Texture ?"

Jun 04 '10 at 10:26 AM stephane
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x191
x55
x16

asked: Jun 03 '10 at 04:04 PM

Seen: 1570 times

Last Updated: Jun 03 '10 at 05:01 PM