ソースコード
using System;
public static class MulticastDelegateExtensions
{
public static int GetLength( this MulticastDelegate self )
{
if ( self == null || self.GetInvocationList() == null )
{
return 0;
}
return self.GetInvocationList().Length;
}
}
使い方
Action act = null;
Debug.Log( act.GetLength() );
act += () => {};
Debug.Log( act.GetLength() );
act += () => {};
act += () => {};
act += () => {};
act += () => {};
Debug.Log( act.GetLength() );
act = () => {};
Debug.Log( act.GetLength() );
act = null;
Debug.Log( act.GetLength() );
関連記事