Exemplo n.º 1
0
        //绑定带参数的command
        public void BindCommand <TComponent, TData>
            (TComponent component, Action <TData> command, UnityEvent <TData> componentEvent = null,
            Func <Action <TData>, Action <TData> > wrapFunc = null) where TComponent : class
        {
            var bind = new BindCommandWithPara <TComponent, TData>(component, command, componentEvent, wrapFunc);

            Binds.Add(bind);
        }
Exemplo n.º 2
0
 //绑定带参数的command
 public void BindCommand <TComponent, TData>
     (TComponent component, Action <TData> command, UnityEvent <TData> componentEvent = null,
     Func <Action <TData>, Action <TData> > wrapFunc = null) where TComponent : class
 {
     Index++;
     if (!TryGetBinder <BindCommandWithPara <TComponent, TData> >(out var result,
                                                                  (bind) => { bind.UpdateValue(component, command, componentEvent, wrapFunc); }))
     {
         result             = new BindCommandWithPara <TComponent, TData>(component, command, componentEvent, wrapFunc);
         CacheBinder[Index] = result;
     }
 }
Exemplo n.º 3
0
        //绑定带参数的command
        public void BindCommand <TComponent, TData>
            (TComponent component, Action <TData> command, UnityEvent <TData> componentEvent = null,
            Func <Action <TData>, Action <TData> > wrapFunc = null) where TComponent : class
        {
            BindCommandWithPara <TComponent, TData> bind;

            if (CacheBinds.Count > 0)
            {
                bind = (BindCommandWithPara <TComponent, TData>)CacheBinds.Dequeue();
            }
            else
            {
                bind = new BindCommandWithPara <TComponent, TData>(Container);
            }
            bind.Reset(component, command, componentEvent, wrapFunc);
            AddClearable(bind);
        }