i can easily get and set float values through reflection
Code: Select all
Type ownType = this.GetType();
PropertyInfo infos = ownType.GetProperty(property, BindingFlags.Instance | BindingFlags.NonPublic);
float tempFloat = 0.1f;
if( info.PropertyType.Equals(tempFloat.GetType()))
{
info.SetValue(this, tempFloat);
float f = (float) info.GetValue(this);
Ventuz.Kernel.VLog.Info("float: "+f);
}
Code: Select all
if( info.PropertyType.Equals(tempInt.GetType()))
{
info.SetValue(this, tempInt );
int i = (int) info.GetValue(this);
Ventuz.Kernel.VLog.Info("int: " + i);
}
09:07 11.06.2015 Info : : System.ArgumentException: Property set method not found.
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at Script.OnMethod1(Int32 arg)
what am I doing wrong?
bashy