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

How to implement a horizontal line in a text component

Discussion in 'Editor & General Support' started by kensarto17, Feb 22, 2020.

  1. kensarto17

    kensarto17

    Joined:
    Nov 11, 2017
    Posts:
    27
    I am looking to replicate the appearance of the <hr> tag from html within a text component as a means of dividing different sections of information. I would prefer this occur within script rather than via editor.

    If this can not be done, is there a way to emulate this appearance via the use of multiple text components or other UI elements. Preferably i would just like to use 1 text component because it keeps the script cleaner, but i'll take what I can get.
    Below is an example of the appearance i am looking to emulate.
    upload_2020-2-22_22-51-35.png

    Edit: a possible solution that I require some help implementing would be to insert X amount of the _ symbol to substitute a true <hr> type feature. If you know of a way to find the width of the text component after all of its text has been added, and then translate that into a number of symbols to be inserted without making the window any wider (important), please inform me of how to do that as it is a solution I will readily accept.
     
    Last edited: Feb 22, 2020
  2. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    maybe use
    3405204603_0dffc37848_o_400x400.png
     
    bloxorz51 likes this.
  3. kensarto17

    kensarto17

    Joined:
    Nov 11, 2017
    Posts:
    27
    Is there a good method to find the number of underlines I would need to input into a text box to make sure it properly seperates the entire width of the UI?

    It will need a different width for multiple different instances, and going forward just manually inputting it for every circumstance won't be suitable.

    I tested the appearance of a series of that symbol and it looks acceptable enough, so if a way to determine the number of symbols to use in each given circumstance is available, it will be a great solution.
     
  4. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
  5. kensarto17

    kensarto17

    Joined:
    Nov 11, 2017
    Posts:
    27
    Unless I am mistaken, isnt that for use in creating inspectors for the editor, rather than UI elements for the project itself?

    I could be mistaken of course, but I'm not seeing anything from there that affects UI.
     
  6. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    yes u are right, i apologise
     
  7. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    u could use first method and do character count but all depending on font default width so not ideal in any way
     
    Last edited: Feb 23, 2020