除了低级原生插件接口之外,Unity 还支持对着色器编译器的低级访问,从而允许用户将不同的变体注入着色器。这也是一种事件驱动的方法:当某些内置事件发生时,插件将接收回调。
Unity 公开的着色器编译器访问扩展定义位于 IUnityShaderCompilerAccess.h 中,随 Editor 提供。
目前仅在 D3D11 上支持这些扩展。随后将有更多平台支持这些扩展。
为了利用渲染扩展,插件应导出 UnityShaderCompilerExtEvent。include 文件中提供了大量文档。
只要 Unity 触发其中一个内置事件,就会通过 UnityShaderCompilerExtEvent 调用插件。还可使用脚本通过 CommandBuffer.IssuePluginEventAndData 或 CommandBuffer.IssuePluginCustomBlit 命令将回调添加到 CommandBuffers。
除了基本脚本接口之外,Unity 中的原生代码插件还可以在发生某些事件时接收回调。这主要用于实现插件中的低级渲染,并使低级渲染能够与 Unity 的多线程渲染一起使用。
定义 Unity 所公开的接口的头文件随 Editor 一起提供。
Unity 提供了一个配置着色器编译器访问的接口 (IUnityShaderCompilerExtPluginConfigure)。此接口由插件用于保留自己的关键字并配置着色器程序和 GPU 程序编译器掩码(应该调用插件的着色器或 GPU 程序的类型)
Unity 2017.1 中的新功能 NewIn20171
2017–07–04 页面已发布
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.