开发者

IronPython: Trouble building a WPF ShaderEffect

开发者 https://www.devze.com 2022-12-14 08:05 出处:网络
I\'m trying to build an extensible program where users, among other things, can build their own shader effects.

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 appreciat开发者_StackOverflow社区ed.

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


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)
0

精彩评论

暂无评论...
验证码 换一张
取 消