IronPython:构建 WPF ShaderEffect 时遇到问题

发布于 2024-08-15 17:33:39 字数 526 浏览 2 评论 0原文

我正在尝试构建一个可扩展的程序,用户可以在其中构建自己的着色器效果。

谷歌搜索让我走到了这一步;

class Test(ShaderEffect):
    inputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", type(Test()), 0)

但我仍然收到错误;

类型错误:无法访问受保护的 成员 注册PixelShaderSampler属性 没有 python 子类 着色器效果。

任何帮助将不胜感激。

我可以找到网上最好的来源 链接在这里

I'm trying to build an extensible program where users, among other things, can build their own shader effects.

Google searching got me this far;

class Test(ShaderEffect):
    inputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", type(Test()), 0)

But I still get the error;

TypeError: cannot access protected
member
RegisterPixelShaderSamplerProperty
without a python subclass of
ShaderEffect.

Any help would be greatly appreciated.

The best source on the net I could find is linked here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

像极了他 2024-08-22 17:33:39

您将需要使用反射来访问 .NET 类的受保护成员 - 您没有可​​以直接访问此类成员的 Python 子类。

尝试这样的想法(我还没有测试过):

inputPropertyType = ShaderEffect.GetType().GetMember(
    'RegisterPixelShaderSamplerProperty',
    BindingFlags.Instance | BindingFlags.NonPublic)
inputProperty = inputPropertyType.GetValue(ShaderEffect, None)
inputProperty("Input", type(Test()), 0)

You will need to use Reflection to access protected memeber of .NET class - you don't have a Python subclass where you can access such member directly.

Try somethink like this (I have't tested it):

inputPropertyType = ShaderEffect.GetType().GetMember(
    'RegisterPixelShaderSamplerProperty',
    BindingFlags.Instance | BindingFlags.NonPublic)
inputProperty = inputPropertyType.GetValue(ShaderEffect, None)
inputProperty("Input", type(Test()), 0)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文