Shader Graph Create Custom Node

作者 Unity-Technologiesba48956ae8be無授權條款收錄於 2026年10月8日更新於 2026年10月8日

Generates custom Shader Graph nodes from HLSL code. Use when the user wants to create a new Shader Graph node or make existing HLSL code work as a reflected function node.

AI 產生的概覽

依照 HLSL 程式碼產生自訂 Unity Shader Graph 節點,並加上反射提示標籤。

功能
此技能說明如何把 HLSL 程式碼轉為反射函式節點,以建立自訂 Shader Graph 節點。它使用 UNITY_EXPORT_REFLECTION 前置處理器巨集定義 HLSL 函式,並加上 ProviderKey、SearchCategory、SearchTerms 與 DisplayName 等 Shader Graph 提示標籤,最後將程式碼寫入 ShaderInclude(.hlsl)資產。它也會在專案中尋找已包含自訂節點的資產,並在附加前請求確認。
適用情境
當使用者想要建立新的 Shader Graph 節點,或讓現有 HLSL 程式碼在 Unity 中作為反射函式節點使用時,適合使用此技能。
執行需求
需要 Unity Shader Graph 套件 com.unity.shadergraph 17.5.0 或更新版本。僅為指示性內容,未附帶指令碼,但包含一份提示標籤參考檔案。

Generating a custom Shader Graph node

Step 1: Generate an HLSL function definition

  • The function must be preceded by the preprocessor define UNITY_EXPORT_REFLECTION

Step 2: Decorate with Shader Graph hint tags

  • See resources/all_hints.hlsl for all valid hint tags and usage patterns
  • C#-style documentation tags are supported outside of funchints or paramhints blocks
  • Required function hints:
    • sg:ProviderKey
    • sg:SearchCategory
    • sg:SearchTerms
    • sg:DisplayName

Step 3: Write the code to an asset

  • Search the project for a ShaderInclude asset (.hlsl) that already contains custom Shader Graph nodes
  • If a matching asset exists, show the user its current contents and ask for confirmation before appending the new code
  • If no matching asset exists, create a new .hlsl asset
  • Ensure the file begins with #include "ShaderApiReflectionSupport.hlsl"

來源與署名

來源:Unity-Technologies/unity-agent-plugin位於skills/shader-graph-create-custom-node提交ba48956

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架