Search Unity

Question Linking components to local documentation

Discussion in 'Documentation' started by JasonC_, Mar 28, 2022.

  1. JasonC_

    JasonC_

    Joined:
    Oct 27, 2019
    Posts:
    66
    Is it possible to use local documentation, e.g. HTML files in the Assets folder of a project, as the Help URL for a component?

    If so, what path should I put in the
    HelpURL
    annotation?

    I tried the following annotations with a file at Assets/Documentation/Test.html, but all of them led to the same behavior of nothing happening when I click the help icon for the component in the inspector:

    - [HelpURL("Assets/Documentation/Test.html")]
    - [HelpURL("/Assets/Documentation/Test.html")]
    - [HelpURL("../Documentation/Test.html")] // relative path to script
    - [HelpURL("file://Assets/Documentation/Test.html")]
    - [HelpURL("file:///Assets/Documentation/Test.html")]
    - [HelpURL("Documentation/Test.html")]
    - [HelpURL("/Documentation/Test.html")]
    - [HelpURL("file://Documentation/Test.html")]
    - [HelpURL("file:///Documentation/Test.html")]

    I couldn't think of anything else.

    If this isn't possible, then how is component documentation usually distributed with a package?

    Unity 2020.3.31f1, Windows 10.
     
    MvNimwegen likes this.
  2. MvNimwegen

    MvNimwegen

    Joined:
    Dec 19, 2019
    Posts:
    56
    I am very curious about this too! Anybody has any idea?
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,487
    I'll move this post to the documentation forum but keep a redirect link here. You're likely to get a more useful answer there.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,487
    I'm not sure the answer here, I'm surprised file:// doesn't work. Although not nice, have you perhaps tried a full path from the root. Granted that wouldn't be useful but I'd be curious to know if it works.

    I'm digging through the source here for that attribute but it's not my area of expertise. It does check if it's a well formed URL and an absolute (not relative) one but if not then has an automatic fallback to file although a the moment, I'm not sure if that's a relative path or not; still trying to figure it out.

    Code (CSharp):
    1.             if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
    2.                 Application.OpenURL(url);
    3.             else
    4.                 Application.OpenURL($"file://{url}");
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    seems that file:// cannot use relative paths?
    and env.variables doesn't seem to expand either, so "%TEMP%/myfile.html" didn't work for me..

    quick "workaround" poc (not really practical though)
    - create temporary redirect_comp1.html file in some fixed folder
    - open that file from help url (using absolute path
    Code (JavaScript):
    1. [HelpURL("C:\\yourfolder\\redirect_comp1.html")]
    - that redirect file has one line to the correct path:
    Code (JavaScript):
    1. <meta http-equiv="refresh" content="0; url=file:///D:/yourfolder/anything/project/docs/test1.html" />



    *this is what it tries to run if use
    Code (CSharp):
    1. [HelpURL(("../../log.txt"))]
    upload_2022-9-9_14-6-11.png
     
    Last edited: Sep 9, 2022
  6. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,108
    I'm just adding to the pile but no one tried single dot slash (./), which would be the root access.