コード例 #1
0
ファイル: MonoThread.cs プロジェクト: linml/Assets
    public MonoAction Add(MonoAction monoAction, float delay, AddEnum addEnum = AddEnum.Cancel)
    {
        if (monoAction == null)
        {
            return(null);
        }

        if (addEnum == AddEnum.Cancel && m_MonoAction_list.Contains(monoAction))
        {
            //不需要操作
        }
        else
        {
            monoAction._DelayedTime = System.DateTime.Now.AddSeconds(delay).Ticks;

            lock (m_MonoAction_list)
            {
                //需要删除
                if (addEnum == AddEnum.Override && m_MonoAction_list.Contains(monoAction))
                {
                    m_MonoAction_list.Remove(monoAction);
                }

                //添加
                m_MonoAction_list.Add(monoAction);
            }
        }

        return(monoAction);
    }
コード例 #2
0
ファイル: MonoThread.cs プロジェクト: linml/Assets
    /// <summary>
    ///
    /// </summary>
    /// <param name="action"></param>
    /// <param name="delay">单位秒</param>
    /// <returns></returns>
    public MonoAction Add(System.Action action, float delay = 0, AddEnum addEnum = AddEnum.Cancel)
    {
        if (delay <= 0)
        {
            lock (m_Action_list)
            {
                m_Action_list.Add(action);
            }

            return(null);
        }
        else
        {
            MonoAction monoAction = new MonoAction {
                _Action = action
            };
            return(Add(monoAction, delay, addEnum));
        }
    }