Unity & Doxygen

 • 

三个脚本。
Doxygen 生成的文件位置在与 Assets 同级的 Documentation 文件夹内,Doxyfile 与 GenDoc.command 同级,都在 Assets/FinGameWorks/Scripts/Documentation/ 内


JZDoxygenManager.cs

using UnityEngine;  
using UnityEditor;  
using System.Collections;  
using System.Diagnostics;

namespace FinGameWorks.Editor  
{
    public class JZDoxygenManager : EditorWindow{

        [MenuItem ("Window/FinGameWorks/Documentation/Gen Doc")]
        static void Init () 
        {
            RegenDoc();
        }

        public static void RegenDoc ()
        {
            Process proc = new System.Diagnostics.Process ();
            proc.StartInfo.FileName = "open";
            proc.StartInfo.Arguments = "-b com.apple.terminal "+ Application.dataPath +  "/FinGameWorks/Scripts/Documentation/GenDoc.command";
            proc.Start();
        }
    }
}

GenDoc.command

cd "$(dirname "$([ -L $0 ] && readlink -f $0 || echo $0)")"  
doxygen Doxyfile  
echo “Generation Done”  
sleep 1  
killall Terminal  

JZ_DocumentationWindow.cs

using UnityEngine;  
using System.Reflection;  
using System.IO;

namespace FinGameWorks.Documentation  
{
    #if UNITY_EDITOR
    using UnityEditor;
    /// <summary>
    /// 文档浏览器窗口
    /// </summary>
    [InitializeOnLoad]
    public class JZ_DocumentationWindow : ScriptableObject
    {
        static BindingFlags Flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;

        [MenuItem("Window/FinGameWorks/Documentation/Show Doc")]
        static void Open()
        {

        #if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)

         var type = Types.GetType ("UnityEditor.Web.WebViewEditorWindow", "UnityEditor.dll");
        var methodInfo = type.GetMethod ("Create", Flags);
        methodInfo = methodInfo.MakeGenericMethod (typeof(JZ_DocumentationWindow));

        #elif UNITY_5_4

        var type = Types.GetType ("UnityEditor.Web.WebViewEditorWindowTabs", "UnityEditor.dll");
        var methodInfo = type.GetMethod ("Create", Flags);
        methodInfo = methodInfo.MakeGenericMethod (type);

        #endif

            string path = Directory.GetParent(Application.dataPath).FullName + "/Documentation/html/index.html";
            methodInfo.Invoke(null, new object[]
            {
                "Documentation",
                path,
                200, 530, 800, 600
            });
        }
    }
    #endif
}