1
화합의 응용 프로그램을 개발했습니다. 앱이 포 그라운드와 배경에있을 때 어떤 작업을 수행하고 싶습니다. 지금은 재귀 적 방식으로 여러 시간 간격으로 로그를 인쇄하려고합니다. 이 방법을 사용하여 카운트 다운 타이머를 호출합니다.Unity 앱이 백그라운드에서 작동하지 않습니다.
void OnApplicationFocus(bool hasFocus){
StartBattle();
isPaused = !hasFocus;
Debug.Log("isPaused " + isPaused);
}
void OnApplicationPause(bool pauseStatus){
isPaused = pauseStatus;
StartBattle();
}
그리고이 방법은 재귀 적으로 데이터를 인쇄합니다.
public void StartBattle(){
StartCoroutine(BattleRecursive(0));
}
public IEnumerator BattleRecursive(int depth){
// Start Coroutine"
yield return new WaitForSeconds(2f);
if (depth == 0)
yield return StartCoroutine(BattleRecursive(depth + 1));
if (depth == 1)
yield return StartCoroutine(BattleRecursive(depth + 1));
Debug.Log("MyCoroutine is now finished at depth " + depth);
}
응용 프로그램이 포 그라운드 인 경우 로그가 잘 인쇄되지만 응용 프로그램이 백그라운드 일 때는 인쇄되지 않습니다.
그래, 지금이 솔루션을 시도하고있다. –