Ejemplo n.º 1
0
                /************************************************************************************************************************/

                /// <summary>
                /// Determines if the `callback` contains any method calls that will be serialized (otherwise the
                /// <see cref="DummyCallback"/> can be used instead of creating a new delegate to invoke the empty
                /// `callback`).
                /// </summary>
                public static bool HasPersistentCalls(SerializableCallback callback)
                {
                    if (callback == null)
                    {
                        return(false);
                    }

                    // UnityEvents do not allow us to check if any dynamic calls are present.
                    // But we are not giving runtime access to the events so it does not really matter.
                    // UltEvents does allow it (via the HasCalls property), but we might as well be consistent.

#if ANIMANCER_ULT_EVENTS
                    var calls = callback.PersistentCallsList;
                    return(calls != null && calls.Count > 0);
#else
                    return(callback.GetPersistentEventCount() > 0);
#endif
                }
Ejemplo n.º 2
0
 /// <summary>
 /// If the `callback` has any persistent calls, this method returns a delegate to call its
 /// <see cref="SerializableCallback.Invoke"/> method. Otherwise it returns the
 /// <see cref="DummyCallback"/>.
 /// </summary>
 public static Action GetInvoker(SerializableCallback callback)
 {
     return(HasPersistentCalls(callback) ? callback.Invoke : DummyCallback);
 }