x


how to make textArea or a textfield uneditable?

I just want it to display text. so it's not modifyable. How could it be done? or is there some better way to display text than text area or text field?

more ▼

asked Sep 25, 2010 at 10:21 PM

dot gravatar image

dot
585 220 170 173

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

4 answers: sort oldest

You can use GUI.Label or GUI.Box (if you want a background) instead

If you want to make a textbox uneditable, just don't store the return from the textbox function. It'll only change if you're storing the new value to the variable you're displaying

more ▼

answered Sep 25, 2010 at 10:54 PM

Mike 3 gravatar image

Mike 3
32.9k 19 80 290

thank you. I guess I was so out there to test it as fast as I can, that I forgot "ticking" your answer. Thanks

Sep 30, 2010 at 03:44 AM dot
(comments are locked)
10|3000 characters needed characters left

An even better way of getting the textfield format but leave it uneditable like a lable, is to make a label with a textfield format, like so:

GUI.Label(Rect(x,y,width,height),VariableName,"TextField");
more ▼

answered Nov 15, 2012 at 09:41 AM

shaystibelman gravatar image

shaystibelman
317 40 34 37

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

tihs code is true for you:
GUI.TextField(Rect(x,y,width,height)),text,"TextField");
just don't save return value from GUI.TextField

more ▼

answered Nov 18, 2012 at 06:16 AM

daivd.ramz gravatar image

daivd.ramz
62 39 947 57

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

Here's another option which provides select/copy abilities...

void ReadOnlyTextField(string label, string text)
{
    EditorGUILayout.BeginHorizontal();
    {
        EditorGUILayout.LabelField(label, GUILayout.Width(EditorGUIUtility.labelWidth - 4));
        EditorGUILayout.SelectableLabel(text, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
    }
    EditorGUILayout.EndHorizontal();
}
more ▼

answered Apr 03 at 08:25 PM

Jason.King gravatar image

Jason.King
66 7 10 20

(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:

x237
x75

asked: Sep 25, 2010 at 10:21 PM

Seen: 5797 times

Last Updated: Apr 03 at 08:25 PM