Skip to content

PropertyDrawerInjector error for newer versions of Unity [2022.3.24 & above] #18

@TJ-Sentient

Description

@TJ-Sentient

NOTE: Your issue may already be reported! Please search on the issue tracker before creating one.

Describe the bug
There is a null reference exception when using reflection to find the property drawer type.

To Reproduce
Steps to reproduce the behavior:

  1. Import package into Unity v2022.3.24.f1 or above
  2. Console will show an error regarding reflection
  3. It references "PropertyDrawerInjector.cs" line 16

Additional context
The error occurs in the following lines :
private static readonly Type s_TypeDrawerKeySet = Type.GetType("UnityEditor.ScriptAttributeUtility+DrawerKeySet, UnityEditor");
private static readonly FieldInfo s_FiDrawer = s_TypeDrawerKeySet.GetField("drawer", kBfAll);
private static readonly FieldInfo s_FiType = s_TypeDrawerKeySet.GetField("type", kBfAll);

The script tries to get TypeDrawerKeySet in UnityEditor.ScriptAttributeUtility. However in the newer versions of unity this struct does not exist. Therefore it leads to a null reference exception.

I hope you can look into this at your earliest convenience and modify the script accordingly for newer unity versions.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleased

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions