Documentation for a Unity Asset

This article shows how to build documentation for a Unity asset in One File Docs and package it inside the asset itself as a locally opened HTML file.

Why use this format

This format lets you ship documentation together with a Unity asset as a single HTML file that opens locally, does not depend on a separate styles or scripts folder, works well inside an Asset Store package, and stays usable for offline or client-side delivery.

A quick entry point with Asset Doc Wizard

Asset Doc Wizard is a free Unity asset for quickly creating a polished entry point for local HTML documentation. Its visual wizard helps connect the documentation to a Unity asset, configure the logo, title, version, and description, add website and support links, and open the HTML file in the default web browser.

If you prefer a fully manual setup, the example below shows how to build it with a ScriptableObject and a custom inspector.

How to plan the structure

It helps to sketch the documentation structure first and export the final HTML after that. For a Unity asset, several focused pages often work better than one long article.

For example, the structure can look like this:

  • Overview or What is this asset with the short value proposition and the main capabilities.
  • Quick Start with the shortest path from package import to the first working result.
  • Setup with dependencies, scene requirements, inspector settings, and mandatory post-import steps.
  • Examples for common scenarios such as basic usage, runtime integration, and editor-side workflows.
  • Troubleshooting for empty scenes, missing references, incorrect configuration, and recovery checks.
  • Release Notes or Migration when version changes matter for existing projects.
  • API Reference when the asset exposes a meaningful public C# surface.

A Unity asset documentation tree can look like this:

Documentation
├─ Overview
├─ Quick Start
├─ Setup
├─ Examples
│  ├─ Basic Example
│  ├─ Runtime Example
│  └─ Editor Example
├─ Troubleshooting
├─ Migration
└─ API Reference

How to place files inside the package

After that, export the documentation into a single HTML file and place it inside the asset package. A practical folder layout can look like this:

.../Your Asset/
├─ Documentation/
│  ├─ Documentation.asset
│  └─ Content/
│     └─ Documentation-Content.html
├─ Scripts/
│  ├─ Documentation/
│  │  └─ Documentation.cs
│  └─ Editor/
│     └─ Editors/
│        └─ DocumentationEditor.cs

If you already have a concrete project structure, the final paths can differ. For example, the exported HTML may live at Documentation/Content/Documentation-Content.html, while Documentation.asset serves as a separate entry point for local documentation inside the project. This keeps the HTML inside a service folder while the user opens the documentation through the asset or an editor button.

One practical file setup looks like this:

  • Documentation-Content.html as the exported One File Docs document.
  • Documentation.cs as a ScriptableObject that acts as the documentation entry point.
  • DocumentationEditor.cs as a custom inspector with a button for opening local documentation.
  • Documentation.asset as the ready-to-open asset users can select in the Project window and use as a documentation hub.

This makes the documentation part of the package. After importing the asset, the user can select Documentation.asset in the Project window and open the local HTML file directly from the Inspector.

How to open HTML in the Unity Editor

Inside the Unity Editor, a user will not open the HTML file directly from the Inspector as a built-in preview. The usual pattern is to open local documentation programmatically through a custom inspector button, a menu item, or another editor action.

Documentation.cs example

using UnityEngine;

namespace MyAsset
{
    [CreateAssetMenu(fileName = "Documentation", menuName = "MyAsset Documentation/Documentation")]
    public class Documentation : ScriptableObject
    {
        // This class can stay empty.
        // It only connects Documentation.asset
        // with the custom inspector in DocumentationEditor.cs.
    }
}

DocumentationEditor.cs example

using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace MyAsset
{
    [CustomEditor(typeof(Documentation))]
    public class DocumentationEditor : Editor
    {
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (GUILayout.Button("Open Documentation"))
            {
                string assetPath = AssetDatabase.GetAssetPath(target);
                string assetDirectory = Path.GetDirectoryName(assetPath);
                string fullPath = Path.GetFullPath(Path.Combine(assetDirectory, "../Documentation/Content/Documentation-Content.html"));

                if (!File.Exists(fullPath))
                {
                    Debug.LogWarning("Documentation file not found: " + fullPath);
                    return;
                }

                Application.OpenURL(new Uri(fullPath).AbsoluteUri);
            }
        }
    }
}

How it works for the user

With this setup, Documentation.asset becomes the entry point, while the inspector code itself fully controls how the local HTML file is opened.