Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: yuewah on October 28, 2014, 04:15:58 AM

Title: why EventDelegate allow 'void' return type only ?
Post by: yuewah on October 28, 2014, 04:15:58 AM
why EventDelegate allow 'void' return type only ? Is it possible to support 'bool' return type ?
Title: Re: why EventDelegate allow 'void' return type only ?
Post by: yuewah on October 28, 2014, 04:44:16 AM
If it can not support return type, is it possible to support getting the result in parameter with reference, i.e. ( out bool result ) ?
Title: Re: why EventDelegate allow 'void' return type only ?
Post by: yuewah on October 28, 2014, 05:41:55 AM
In order to support parameter with reference, just modify EventDelegate.cs a bit

  1.  [System.NonSerialized] ParameterInfo[] mParameterInfos;
  2.  
  3.  mParameterInfos = mMethod.GetParameters();
  4.  
  5. for (int i = 0, imax = mArgs.Length; i < imax;  ++i)
  6. {
  7.           if ( mParameterInfos[i].IsIn || mParameterInfos[i].IsOut )
  8.           {
  9.                mParameters[i].value = mArgs[i];
  10.           }
  11.           mArgs[i] = null;
  12. }
  13.