Property drawers in DLL cause errors

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.

Interesting… sounds like you might have encountered a bug here. Could you report a bug with a project and dll in question? After reporting, post the case number here and we can dig into it.

Yes, I’ll try to strip the project down a bit soon so it’s smaller and less messy and then send you the files.

Thanks!

First of all, sorry for (very) late reply now. I got really busy with other things.
I copied project folder and started deleting things today - however, I noticed there’s no error now. I checked the main, unstripped project too, restarted editor as well, and there’s no error.
Should I send the smaller one with deleted things anyway for more investigation? I will keep eye out for the same issue happening again and will send asap then, can’t promise how fast will this happen, though.