Qual a diferença entre o Invoke e InvokeRepeating? public abstract class…
- User
Qual a diferença entre o Invoke e InvokeRepeating?
public abstract class FacepunchBehaviour : MonoBehaviour { public void Invoke(Action action, float time) { InvokeHandler.Invoke(this, action, time); }
codepublic void Invoke(Action action, float time, float random) { time += UnityEngine.Random.Range(0f - random, random); InvokeHandler.Invoke(this, action, time); } public void InvokeRepeating(Action action, float time, float repeat) { InvokeHandler.InvokeRepeating(this, action, time, repeat); } public void InvokeRandomized(Action action, float time, float repeat, float random) { InvokeHandler.InvokeRandomized(this, action, time, repeat, random); } public void CancelInvoke(Action action) { InvokeHandler.CancelInvoke(this, action); } public bool IsInvoking(Action action) { return InvokeHandler.IsInvoking(this, action); } public void InvokeRepeatingFixedTime(Action action) { InvokeHandlerFixedTime.InvokeRepeating(this, action, 0.01f, 0.01f); } public void InvokeRandomizedFixedTime(Action action, float time, float repeat, float random) { InvokeHandlerFixedTime.InvokeRandomized(this, action, time, repeat, random); } public void CancelInvokeFixedTime(Action action) { InvokeHandlerFixedTime.CancelInvoke(this, action); } public bool IsInvokingFixedTime(Action action) { return InvokeHandlerFixedTime.IsInvoking(this, action); }}
- Assistant
A diferença entre
InvokeeInvokeRepeatingno contexto de Unity, e mais especificamente no código fornecido que parece usar um sistema personalizado de invocação, geralmente se refere à frequência com que uma ação ou método é chamado:-
Invoke:
- É utilizado para chamar uma função após um tempo especificado.
- No código apresentado, há duas variações:
Invoke(Action action, float time): Chama a ação uma única vez após um tempo determinado (time).Invoke(Action action, float time, float random): Chama a ação uma vez após um tempotimeajustado por um valor aleatório dentro do intervalo definido porrandom.
-
InvokeRepeating:
- É usado para chamar uma função repetidamente em um intervalo de tempo definido.
-