I am using reflection in an editor script. The script looks up all of the components on a GameObject and returns their properties with GetProperties();
Some properties are obsolete and return an error when used in conjunction with GetValue such as:
minVolume is not supported anymore. Use min-, maxDistance and rolloffMode instead.
System.Reflection.MonoProperty:GetValue(Object, Object[])
How can we check for these obsolete properties or simply avoid having to see these error messages?
try{
propertyValue = propertyInfo.GetValue(myComponent,null);
} catch {
// is not catching the error
}
Edit: The problematic properties I’ve found were “rolloffFactor”,“minVolume”, and “maxVolume” which are all from AudioSource. My current workaround is to check for these property names and skip them.