mob-sakai / UnityEventDrawerEx

This plugin extends the UnityEventDrawer to display runtime calls in the inspector.
MIT License
94 stars 12 forks source link

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

Closed TJ-Sentient closed 1 month ago

TJ-Sentient commented 1 month ago

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.

mob-sakai commented 1 month ago

Thank you for your reporting!

github-actions[bot] commented 1 month ago

:tada: This issue has been resolved in version 1.0.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: