Пример #1
0
 private void initUUpdater()
 {
     if (updater == null)
     {
         updater           = gameObj.AddComponent <UUpdater>();
         updater.onUpdate += () =>
         {
             if (waitForAddFuncs.Count > 0)
             {
                 updateActions.AddRange(waitForAddFuncs);
                 waitForAddFuncs.Clear();
             }
             if (updateActions.Count > 0)
             {
                 var remove = new List <Func <bool> >();
                 foreach (var u in updateActions)
                 {
                     if (u())
                     {
                         remove.Add(u);
                     }
                 }
                 foreach (var r in remove)
                 {
                     updateActions.Remove(r);
                 }
             }
         };
     }
 }
Пример #2
0
    private void initUUpdater()
    {
        if (gameObj == null)
        {
            return;
        }
        if (updater == null)
        {
            updater           = gameObj.AddComponent <UUpdater>();
            updater.onUpdate += () =>
            {
                if (waitForAddFuncs.Count > 0)
                {
                    updateActions.AddRange(waitForAddFuncs);
                    waitForAddFuncs.Clear();
                }
                if (updateActions.Count > 0)
                {
                    var remove = new List <Func <bool> >();
                    foreach (var u in updateActions)
                    {
                        /*try
                         * {*/
                        if (u())
                        {
                            remove.Add(u);
                        }

                        /*}
                         * catch (Exception ex)
                         * {
                         *      UDebugHotLog.Log($"update error:\r\n{this.GetType().FullName}\r\n{ex.Message}\r\n{ex.StackTrace}");
                         *      remove.Add(u);
                         * }*/
                    }
                    foreach (var r in remove)
                    {
                        updateActions.Remove(r);
                    }
                }
            };
        }
    }