Hello I hope you are doing well! Thanks again for the great support and BT product here. Just a quick question regarding the ObjectDrawer its fieldInfo member.
Goal:
I want to be able to access type information regarding the field is being drawn by a custom ObjectDrawer.
Problem:
fieldInfo is not set when the ObjectDrawer is created from an ObjectDrawerAttribute attribute. Not sure if leaving this null in the case of an attribute triggered ObjectDrawer is by design or not. If so, how can I determine the type of the field that is being drawn? My thoughts are that it is a bug. In any case, here are the specifics:
Here is a a trivial example :
The ObjectDrawer is created through the overload of GetObjectDrawer. In this version of the method, the objectDrawer fieldInfo is not set.
Minor API change request:
The sender of GetObjectDrawer has a reference to the fieldInfo instance. It can easily be passed down via a minor refactor to the ObjectDrawerForType method prototype.
As always, thanks for the ongoing support on the Behaviour Designer asset!
W
Goal:
I want to be able to access type information regarding the field is being drawn by a custom ObjectDrawer.
Problem:
fieldInfo is not set when the ObjectDrawer is created from an ObjectDrawerAttribute attribute. Not sure if leaving this null in the case of an attribute triggered ObjectDrawer is by design or not. If so, how can I determine the type of the field that is being drawn? My thoughts are that it is a bug. In any case, here are the specifics:
Here is a a trivial example :
Code:
public class MyTask : Conditional
{
[BTObjectReference]
private Foo m_Foo;
}
[CustomPropertyDrawer ( typeof( AssigmentCheck ) )]
public class BTObjectReferenceAttribute : ObjectDrawerAttribute
{
}
[CustomObjectDrawer ( typeof( BTObjectReferenceAttribute ) )]
public class BTObjectReferenceDrawer : ObjectDrawer
{
//-- fieldInfo is null but it should report info about m_Foo
Object input = EditorGUILayout.ObjectField( label, (Object) value,fieldInfo.FieldType true ); // <-- fieldInfo is null :( :(
}
The ObjectDrawer is created through the overload of GetObjectDrawer. In this version of the method, the objectDrawer fieldInfo is not set.
Minor API change request:
The sender of GetObjectDrawer has a reference to the fieldInfo instance. It can easily be passed down via a minor refactor to the ObjectDrawerForType method prototype.
Code:
if ((customAttributes = field.GetCustomAttributes(typeof (ObjectDrawerAttribute), true) as ObjectDrawerAttribute[]).Length <= 0
|| (objectDrawer2 = ObjectDrawerUtility.GetObjectDrawer(field, task, customAttributes[0])) == null)
As always, thanks for the ongoing support on the Behaviour Designer asset!
W
Attachments
Last edited: