Quote:Original post by roastedamoeba
Cannot take the address or size of a variable of a managed type ('object')
The compiler says that even if you pass it a struct (i.e. not boxed into an object).
Yes, you can only take the address of value types (ie. structs) in that way. That said, if you are passing structures into your effects you should probably be using structs and even explicitly laying out the varaibles in your struct with the StructLayout attribute. (then you know the size too).
The other way to access the members of structs in your effect is to pass the EffectHandle of the sturct as the first argument to GetParameter and the name of the member as the second. When you are accessing an array you can also use GetParameterElement to get a handle on a single element of the array.
//Struct:
EffectHandle structHandle = effect.GetParameter(null,"someStruct");
EffectHandle memberHandle = effect.GetParameter(structHandle,"someMember");
//Array:
EffectHandle arrayHandle = effect.GetParameter(null,"someArray");
EffectHandle thirdElementHandle = effect.GetParameterElement(structHandle,2);
One more thing:
Microsoft.DirectX.DXHelp several methods to 'help' with this stuff: CopyObjectDataToPointer, CopyPointerDataToObject, GetObjectSize and GetTypeSize.