Custom help for editor scripts?

I was wondering if there is a way to customize the help URL for the little book icon in the inspector? Presently I’m using my own help button, but thought it would tidy things up to use the existing UI. Is this possible?

3 Answers

3

It seems that it’s not possible. The function InspectorTitlebar that is used to display the title bar of an inspector uses this code to display the help icon:

if (Help.HasHelpForObject(targetObj))
{
    Rect position4 = rect2;
    position4.x -= 18f;
    if (GUI.Button(position4, EditorGUI.s_HelpIcon, inspectorTitlebarText))
    {
        Help.ShowHelpForObject(targetObj);
    }
    position2.xMax = position4.xMin - 2f;
}

The functions Help.HasHelpForObject and Help.ShowHelpForObject are mapped to native code so it seems to be “hard-coded”.

I agree that it would be a nice feature to display a custom help page or even better to have a callback for this button :wink:

Ok, thanks for the help. I've found that I can either create my own button and/or use @MenuItem to insert a help item in the drop down menu.

–

This is really a shame. Maybe the Unity guys can keep this in mind for future releases.

–

Feel free to post a <a href="http://feedback.unity3d.com/forums/15792-unity">feature request</a> ;) But think about your words carefully. You have to convince others so they vote for your idea.

–

I agree, this would allow extension developers to integrate their documentation in the way that Unity users have become accustomed to.

–

Might make sense to add another parameter to the CustomEditorAttribute indicating the documentation URL. In the meantime, you could probably put your own button on top of the standard one, as I suggested in an answer to this question -- http://answers.unity3d.com/questions/373334/how-can-i-link-to-my-doc-in-a-customer-inspector-p.html

–

Use HelpURLAttribute.

[HelpURL("http://example.com/docs/MyComponent.html")]
public class MyComponent
{
   
}

Seems like this isn’t possible, but for now my solution is putting this in my MonoBehaviour:

[MenuItem("CONTEXT/Tile/Help")]
static void Help ()
{
	Application.OpenURL ("http://myhelppage.com");
}

This adds a Help entry to the Context menu for the current script. When you either right click on Script title bar or click on the little drop down menu in next to the help book, this menu comes up.

Hi, this context help is now working differently: http://docs.unity3d.com/Documentation/ScriptReference/ContextMenu.html

–

Great, thanks!

–

No, it doesn't work differently now. ContextMenu is a new attribute that can be used directly in runtime classes, so you can add a context menu item directly to the MonoBehaviour itself. The <a href="http://docs.unity3d.com/Documentation/ScriptReference/MenuItem.html" rel="nofollow">MenuItem</a> attribute is still valid, but it works differently. The function that should be called have to be static and have to be defined in any editor class.

–

Hi bunny83, thanks for the clarifications

–