예제 #1
0
    /// <summary>
    /// Remove an existing event delegate from the list.
    /// </summary>

    static public bool Remove(List <UEEventDelegate> list, UEEventDelegate ev)
    {
        if (list != null)
        {
            for (int i = 0, imax = list.Count; i < imax; ++i)
            {
                UEEventDelegate del = list[i];

                if (del != null && del.Equals(ev))
                {
                    list.RemoveAt(i);
                    return(true);
                }
            }
        }
        return(false);
    }
예제 #2
0
    /// <summary>
    /// Append a new event delegate to the list.
    /// </summary>

    static public UEEventDelegate Add(List <UEEventDelegate> list, Callback callback, bool oneShot)
    {
        if (list != null)
        {
            for (int i = 0, imax = list.Count; i < imax; ++i)
            {
                UEEventDelegate del = list[i];
                if (del != null && del.Equals(callback))
                {
                    return(del);
                }
            }

            UEEventDelegate ed = new UEEventDelegate(callback);
            ed.oneShot = oneShot;
            list.Add(ed);
            return(ed);
        }
        Debug.LogWarning("Attempting to add a callback to a list that's null");
        return(null);
    }
예제 #3
0
    /// <summary>
    /// Append a new event delegate to the list.
    /// </summary>

    static public void Add(List <UEEventDelegate> list, UEEventDelegate ev, bool oneShot)
    {
        if (ev.mRawDelegate || ev.target == null || string.IsNullOrEmpty(ev.methodName))
        {
            Add(list, ev.mCachedCallback, oneShot);
        }
        else if (list != null)
        {
            for (int i = 0, imax = list.Count; i < imax; ++i)
            {
                UEEventDelegate del = list[i];
                if (del != null && del.Equals(ev))
                {
                    return;
                }
            }

            UEEventDelegate copy = new UEEventDelegate(ev.target, ev.methodName);
            copy.oneShot = oneShot;

            if (ev.mParameters != null && ev.mParameters.Length > 0)
            {
                copy.mParameters = new Parameter[ev.mParameters.Length];
                for (int i = 0; i < ev.mParameters.Length; ++i)
                {
                    copy.mParameters[i] = ev.mParameters[i];
                }
            }

            list.Add(copy);
        }
        else
        {
            Debug.LogWarning("Attempting to add a callback to a list that's null");
        }
    }