I have an error when using Tweens with listeners that belong to custom classes, not MonoBehaviours
InvalidCastException: Cannot cast from source type to destination type. EventDelegate.Equals (System.Object obj) "EventDelegate.cs:118"
I have a class: Custom
I have a tween on a MonoBehaviour
I access the tween from the Custom class
I add a delegate for the tween that is a method in my Custom class
EventDelegate.cs:118 tries to check for the existance of that delegate (happens only with REFLECTION_SUPPORT on)
The fail is because of (MonoBehaviour)callback.Target -> This causes an InvalidCastException
The fix:
Please check for callback.Target is MonoBehaviour && mTarget == callback.Target as MonoBehaviour
OR simpler
mTarget == callback.Target as MonoBehaviour
The as cast will evaluate to null but won't throw an exception