Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
6
Question by dot · Sep 25, 2010 at 10:21 PM · textfieldtextarea

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Mike 3 · Sep 25, 2010 at 10:54 PM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dot · Sep 30, 2010 at 03:44 AM 0
Share

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

avatar image
14

Answer by Jason-King · Apr 03, 2014 at 08:25 PM

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();
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Termitoss · Aug 14, 2015 at 06:16 PM 0
Share

Thanks! That's just what I needed, SelectableLabel :)

avatar image soydasmemet · Jan 16, 2016 at 12:57 PM 0
Share

The selectablelabel or EditorGuILayouts dont use for the ios or android apps? Because, they give an error when we build the app for those platforms.

avatar image
3

Answer by shaystibelman · Nov 15, 2012 at 09:41 AM

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");
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Abera · Feb 25, 2016 at 07:50 AM 0
Share

Thanks, your comment really helped me.

avatar image
1

Answer by daivd.ramz · Nov 18, 2012 at 06:16 AM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by isgoed · Nov 25, 2019 at 08:25 AM

I use the following code to have uneditable (but selectable and copyable) text with text-scrollbars:

 void ReadOnlyTextField(string text, float Height)
 {
     scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(Height));
     {
         // Readonly TextArea with working scrollbars
         GUILayout.TextArea(text, EditorStyles.textField, GUILayout.ExpandHeight(true));
     }
     GUILayout.EndScrollView();
 }

The GUILayout.ExpandHeight(true) makes the text-scrollbars work.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Lock a textarea/textfield for editing 1 Answer

TextArea does not fire KeyDown events 1 Answer

Attach Text data to gameobjects by player 0 Answers

TextArea/Field - Individual Character's foreground and background color. 2 Answers

Problem with clearing a textfield in every scene C#. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges