Hi.
I have a simple property drawer code put in DLL.
[CustomPropertyDrawer(typeof(ToggleButtonAttribute))]
public class ToggleButtonAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
ToggleButtonAttribute attr = attribute as ToggleButtonAttribute;
bool value = property.boolValue;
string nameString = attr.NameString == null ? label.text : attr.NameString;
string valueString = value ? attr.TrueString : attr.FalseString;
Rect btnPos = EditorGUI.PrefixLabel(position, new GUIContent(nameString));
if (GUI.Button(btnPos, valueString))
property.boolValue = !value;
}
}
At first it worked fine - I dropped DLL in Editor folder and my button was drawn.
Then at some point I included reference to GUILayout class instead of GUI. I started getting 2 errors.
I reverted changes to the code above, yet the error still happens whenever DLL is in project.
When I delete it, and place the exact same code as a script, it works properly. However starts failing when I drop DLL again - even when I comment out the attributes so the Drawers are not used - DLL just needs to be in the project. Errors stop when there’s no more CustomPropertyDrawer attribute used in the library code - all else fails - even if the property drawer has no OnGUI overriden.
Adding a script in Unity itself as a wrapper
[CustomPropertyDrawer(typeof(ToggleButtonAttribute))]
public class ToggleButtonWrapper : ToggleButtonAttributeDrawer { }
seems to make issue go away, however I find it unnecessary hassle and hope there’s a way to make it work directly from DLL.