• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    해결됨

StartCoroutine("CoStopExplode", 2.0f); 이 부분이 실행이 안됩니다.

22.08.22 17:52 작성 조회수 214

0

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameScene : BaseScene
{
    Coroutine co;

    protected override void Init()
    {
        base.Init();

        SceneType = Define.Scene.Game; 

        Managers.UI.ShowSceneUI<UI_Inven>();

        co = StartCoroutine("ExplodeAfterSeconds", 4.0f);
        StartCoroutine("CoStopExplode", 2.0f);
    
    }

    IEnumerable CoStopExplode(float seconds)
    {
        Debug.Log("Stop Enter");
        yield return new WaitForSeconds(seconds);
        Debug.Log("Stop Execute!!!");
        if (co != null)
        {
            StopCoroutine(co);
            co = null; 
        }
    }

    IEnumerator ExplodeAfterSeconds(float seconds)
    {
        Debug.Log("Explode Enter"); 
        yield return new WaitForSeconds(seconds);
        Debug.Log("Explode Excute!!!");
        co = null; 
    }


    public override void Clear()
    {

    }

}

 

 

        StartCoroutine("CoStopExplode", 2.0f);

BreakPoint 를 여기에 잡아서 유니티에 연결해 실행해 보았지만 두번째 StratCoroutine은 실행이 되지 않고 Stop Enter 로그도 찍히지 않고 넘어가 버립니다. 그냥 Explode Excute가 찍혀버리는데 혹시 StaretCoroutine을 중복 사용할 수 없게 업데이트가 된 걸가요? 

 

답변 2

·

답변을 작성해보세요.

0

밍시님의 프로필

밍시

2023.04.11

이미 해결하셨겠지만, 저도 같은 에러가 떴었어서 코멘트 남겨요!

CoStopExplode(float seconds)

앞에 IEnumerator 아니고 IEnumerable 로 되어있어서 그렇습니다!

baljang님의 프로필

baljang

질문자

2023.04.11

오 그랬군요!!! 감사합니다!!
복습할 때 꼭 해볼게요!! ^^/

0

아뇨 딱히 바뀐 부분은 없을텐데요.
오타가 없는지 한 번 더 확인 해보시고, 그래도 문제 해결이 되지 않는다면
전체 프로젝트를 압축해서 보내주시기 바랍니다.

그리고 요즘은 StartCoroutine() 안에다 "" 문자열로 넣기 보단
CoStopExplode(2.0f) 이런 식으로 바로 넣어줄 수 있습니다.