Skip to content

Commit 34cc2b6

Browse files
committed
[增加]1. 增加终止协程的函数
1 parent 9d7fe61 commit 34cc2b6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Runtime/Utils/Timers.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,24 @@ public void AddUpdate(TimerCallback callback, object callbackParam)
117117
Add(0.001f, 0, callback, callbackParam);
118118
}
119119

120+
/// <summary>
121+
/// 启动协程
122+
/// </summary>
123+
/// <param name="routine"></param>
120124
public void StartCoroutine(IEnumerator routine)
121125
{
122126
_engine.StartCoroutine(routine);
123127
}
124128

129+
/// <summary>
130+
/// 停止协程
131+
/// </summary>
132+
/// <param name="routine"></param>
133+
public void StopCoroutine(IEnumerator routine)
134+
{
135+
_engine.StopCoroutine(routine);
136+
}
137+
125138
public bool Exists(TimerCallback callback)
126139
{
127140
if (_toAdd.ContainsKey(callback))
@@ -160,6 +173,7 @@ private Anymous_T GetFromPool()
160173
}
161174
else
162175
t = new Anymous_T();
176+
163177
return t;
164178
}
165179

@@ -203,6 +217,7 @@ public void Update()
203217
_toRemove.Add(i);
204218
}
205219
}
220+
206221
repeat = i.repeat;
207222
if (i.callback != null)
208223
{
@@ -222,6 +237,7 @@ public void Update()
222237
i.callback(i.param);
223238
}
224239
}
240+
225241
iter.Dispose();
226242
}
227243

@@ -237,6 +253,7 @@ public void Update()
237253
ReturnToPool(i);
238254
}
239255
}
256+
240257
_toRemove.Clear();
241258
}
242259

@@ -277,4 +294,4 @@ void Update()
277294
Timers.inst.Update();
278295
}
279296
}
280-
}
297+
}

0 commit comments

Comments
 (0)