Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Input Field: Making field read-only

Discussion in 'UGUI & TextMesh Pro' started by darkhog, Aug 14, 2015.

  1. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    For instances where you still want people to be able to copy stuff (complex error messages comes to mind) but don't want to overwrite it. Yes, I realize I can make script that constantly puts original value into the field, but Readonly checkbox would be a better solution.
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    This was done not to long ago. I dont think it made it for 5.2 though
     
  3. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    It definitely isn't in 5.1. If it's in git, any idea on how to replace build-in UI components with git version?
     
  4. Carvuh

    Carvuh

    Joined:
    Mar 25, 2013
    Posts:
    25
    Only thing I can think of right now that would be the easiest solution is just have somewhere that you would want to output the message to, lets say a rectangle on the UI, and have a Text object that will fill the same area as the rectangle object.

    Make sure that you have overflow enabled, so that everything will stay inside the area that you specified.

    When you want to output something like an error message, then just do something like:
    Code (csharp):
    1. public Text errorMessage;
    2. errorMessage.text = somethingHere;
    This will allow you to have a message appear that no one can edit, but they wouldnt be able to copy it. I cant really look much further into detail right now, but give some Google searches about used Unity 4.6 GUI with un-editable textAreas.
     
  5. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Yeah, I know about that and as I've said, I could make such script on my own, but checkbox in Input Field's inspector would be better solution.

    But thanks for effort :)