Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: jchowdown on December 11, 2013, 04:59:24 PM

Title: EventDelegate.cs: "unintended reference comparison" warning
Post by: jchowdown on December 11, 2013, 04:59:24 PM
Hi All,

I'm getting this warning in EventDelegate.cs: http://screencast.com/t/lGEf0uyxF5q2

What's the recommended fix please? Should I just #pragma it out for now?

Thanks,
Jeff
Title: Re: EventDelegate.cs: "unintended reference comparison" warning
Post by: rblanchet on December 11, 2013, 05:15:33 PM
This exact diff may not be accurate anymore since I haven't updated NGUI in awhile but it gives you the gist of the change:

  1.  
  2. @@ -98,7 +98,7 @@ public class EventDelegate
  3.      {
  4.        Callback callback = obj as Callback;
  5.        if (callback.Equals(mCachedCallback)) return true;
  6. -      return (mTarget == callback.Target && string.Equals(mMethodName, GetMethodName(callback)));
  7. +      return (mTarget == (MonoBehaviour)callback.Target && string.Equals(mMethodName, GetMethodName(callback)));
  8.      }
  9.      
  10.      if (obj is EventDelegate)
  11. @@ -124,7 +124,7 @@ public class EventDelegate
  12.    Callback Get ()
  13.    {
  14.  #if REFLECTION_SUPPORT
  15. -    if (!mRawDelegate && (mCachedCallback == null || mCachedCallback.Target != mTarget || GetMethodName(mCachedCallback) != mMethodName))
  16. +    if (!mRawDelegate && (mCachedCallback == null || (MonoBehaviour)mCachedCallback.Target != mTarget || GetMethodName(mCachedCallback) != mMethodName))
  17.      {
  18.        if (mTarget != null && !string.IsNullOrEmpty(mMethodName))
  19.        {
  20.  
Title: Re: EventDelegate.cs: "unintended reference comparison" warning
Post by: ArenMook on December 12, 2013, 01:09:00 AM
Those warnings only show up when building in Visual Studio as I understand it (as they certainly don't show up in Unity).

In any case, I've addressed them already yesterday in the Pro repo.
Title: Re: EventDelegate.cs: "unintended reference comparison" warning
Post by: jchowdown on December 12, 2013, 02:27:30 AM
Those warnings only show up when building in Visual Studio as I understand it (as they certainly don't show up in Unity).

In any case, I've addressed them already yesterday in the Pro repo.

Thanks! Not that this is important since you've already addressed it, but I saw this in Unity on OS X.