views:

62

answers:

1

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

A: 

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)
Lukas Cenovsky
Thanks Lukas, I didn't know this could be done.I tried;class Test(ShaderEffect): passinputProperty = Test().GetType().GetMember('RegisterPixelShaderSamplerProperty', BindingFlags.Static)("Input", type(Test()), 0)But I am getting the error; MemberInfo[] is not callable?
Matthew Moloney
My mistake - you have to find out the value. Try the edited version.
Lukas Cenovsky