Unity
μ½λ£¨ν΄ μ€ν μ€μΈμ§ 체ν¬νκΈ°
γ
-γ
2022. 12. 31. 13:02
1. bool λ³μ
2. int
- μ½λ£¨ν΄ μ€ν μ +1, μ’ λ£ μ -1
3. Action
- IEnumerator λ©μλμ μ’ λ£ μ μνν Action λ£μ΄μ£ΌκΈ°
private void Update()
{
bool test1, test2;
StartCoroutine(MoveToDirection(swappingSlotFrom.slotIndex, dragDirection, () =>
{
test1 = true;
}));
StartCoroutine(MoveToDirection(swappingSlotTo.slotIndex, -dragDirection, () =>
{
test2 = true;
}));
}
public IEnumerator MoveToDirection(Vector2Int slotIndex, Vector2Int direction, Action onFinished = null)
{
while(true)
{
// ...
}
onFinished?.Invoke();
}
4. λ¬Άμ IEnumerator
private IEnumerator Swap()
{
isAnimationPlaying = true;
bool test1 = false, test2 = false;
MoveToDirection(swappingSlotFrom.slotIndex, dragDirection, () =>
{
test1 = true;
});
MoveToDirection(swappingSlotTo.slotIndex, -dragDirection, () => {
test2 = true;
});
yield return new WaitWhile(() => test1 && test2);
isAnimationPlaying = false;
}
5. Queue
6. ν΄λμ€ λ§λ€κΈ°
- 1) CustomYieldConstruction μμ
- 2) ν΄λμ€ μμμ μ½λ£¨ν΄ μ€ν, μ’ λ£λ₯Ό κ΄μ₯