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 从公开仓库中收录这些内容。

举报或申请下架