Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Don't miss out on the Unite LA Keynote for the latest information from Unity! Set a reminder!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

html to Text mesh pro?

Discussion in 'Unity UI & TextMesh Pro' started by Shadowing, Oct 6, 2018.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    914
    Has anyone made a thing that converts html to text mesh pro?
    Figure id ask before building one. Can save me some time if one already exists some where.
     
  2. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    914
    bump

    if not how would I do a paragraph tag <p></p> for text mesh rich text?
     
  3. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,739
    A paragraph is typically two consecutive linefeed / char(10) or "\n\n" in the text.
     
  4. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    914
    when i use the page tags <page>fafdafdaf</page>
    TMPro isn't removing the </page>
    <page> tag gets removed just fine


     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,739
    There is no </page> tag. The <page> tag increases the virtual page to force a page break when the text could still fit in the current page / vertical space.
     
  6. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    914
    Thanks @Stephan_B I appreciate the help man.
    How can I handle embed html images with links. Does text Mesh pro have anything for that?
    I read about sprite but that seems just for emoji stuff.

    I'm using this other Text asset that lets me do clickable links like this
    <a class="external_link" name="https://google.com">This is my link to google</a>
    Then I can have a function that controls what happens when a <a> tag with that class name is clicked on.

    Does text mesh pro have anything like that?
    I looked at link for the rich text but that isn't quite the same. Really needs another data field.

    This is a example what i can do with this asset called Candlelight thats now depreciated sadly.
    Code (csharp):
    1.  
    2. <a class="external_link" name="https://google.com"></a>
    3. <a class="guide" name="Tutorials for newbies"></a>
    4.  
    5.  
    6.    public void Link(Candlelight.UI.HyperText hyperText, Candlelight.UI.HyperText.LinkInfo info) {
    7.      
    8.         switch(info.ClassName) {
    9.             case "guide":
    10.                  GuideButton.onClick.Invoke();
    11.         break;
    12.                 case "external_link":
    13.                 ExternalLink(info.Name);
    14.         break;
    15. }
    16. }
    17.  
     
    Last edited: Oct 10, 2018
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,739
    The <link="ID"> tag is what you want to use. Unlike the <a href..> type tags, the link tag allows you to define any behavior you want when hovering over the section of the text enclosed in the link tag.

    See example 12 and 12a included in the TMP Examples and Extras.
     
  8. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    914
    Thanks man im seeing all the examples now.
    Seems to be the same as what it says in the guide.

    See the <link="ID_01">online documentation</link>

    so its just an id tag with content.
    so the only way I can think to do this is to create my own string and parse it?

    See the <link="external_link">This is a link to google#https://google.com</link>
    Probably won't use that as the separator but just an example.
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,739
    Something like <link="ExternalLink_01">This is the text users interact with aka link</link>

    Since you might have several external links, you give each of the unique ones their own ID. Then you can implement any logic you want in terms of what happens when a link is clicked or selected.
     
  10. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    914
    Thanks for all the help man.
    I guess what I was saying is there should be a way to send data with your link. <link="ExternalLink_01" data="My data">
    This way you can create dynamic links/code.

    Code (csharp):
    1.  
    2. <link="external_link" data="https://google.com">This is a link to google</link>
    3.  
    If you have a link that looks like this below. You don't want people to see that huge long ugly link.
    Code (csharp):
    1.  
    2. https://www.google.com/search?q=how+to+fly+kites&rlz=1C1CHBF_enUS817US817&oq=how+to+fly+kites&aqs=chrome..69i57j0l5.2784j0j8&sourceid=chrome&ie=UTF-8
    3.  
    Creating your own separate dictionary for a few links is fine I guess. If you have say 1000 links that wouldn't work with out a data field.
     
    Last edited: Oct 12, 2018