Bomb Kirby Running
Cat Life - GT-K
퍼즐게임 개발일지 - 17

2024. 3. 7. 02:52Game Develop

퍼즐게임 개발일지 17편

영상부터 보시겠습니다

 

 

오늘은 특이하게 영상으로 먼저 시작했다

왜냐면 오늘 어떤걸 고칠지 설명해주고 싶어서

 

참고로 영상은 내 폰으로 찍은거다

후후!

 

암튼 오늘 고칠 것

1. 버튼의 문구가 잘 안바뀜

 

2. 저장된 퍼즐 有 = 플레이 경험

그러나 나오는 프롤로그

 

그럼 레츠꼬

이게 원래 scene을 코드지만

안드로이드 환경이라 적용이 안되는게 아니다

솔직히 게임 뿐만 아니라 다른 어플 사용 하다가

정직하게 어플을 종료하고 나가는 사람?

얼마나 있을까......

일단 난 아님.

 

 

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html

 

Unity - Scripting API: MonoBehaviour.OnApplicationFocus(bool)

OnApplicationFocus is called when the application loses or gains focus. Alt-tabbing or Cmd-tabbing can take focus away from the Unity application to another desktop application. This causes the GameObjects to receive an OnApplicationFocus call with the arg

docs.unity3d.com

유니티 공식 문서 찾아보니

이런게 있더라

(공식문서를 잘 봐야하는 이유)

 

 

백그라운드 어플 2589458개 있는 나는

이걸 보고 왜 안넣었을까....... 싶었다

 

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

public class SceneSaver : MonoBehaviour
{
    
    void OnApplicationFocus(bool hasFocus)
    {
        if (!hasFocus)
        {
            SaveCurrentScene();
        }
    }

    void OnApplicationPause(bool pauseStatus)
    {
        if (pauseStatus)
        {
            SaveCurrentScene();
        }
    }

    void OnApplicationQuit()
    {
        SaveCurrentScene();
    }

    public void SaveCurrentScene()
    {
        PlayerPrefs.SetString("SavedScene", SceneManager.GetActiveScene().name);
        PlayerPrefs.Save();
    }
}

 

암튼 수정한 코드는 이렇다

 

그리고 이어서 프롤로그 부분이다

 

프롤로그의 마지막 대사가 출력되면

Prologue_Scene이름의 boolean을 true로 바꾸어주었다

 

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

public class PrologueManager : MonoBehaviour
{
    void Awake()
    {
        if (PlayerPrefs.GetString("Prologue_" + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name) == "true")
        {
            GetComponent<PlayableDirector>().enabled = false;
        }
    }

}

 

그리고 PrologueManager라는 아주 간단한

코드를 만들어서 Prologue_Scene이름이

true인지 확인하고 true다?(프롤로그 봄)

 

연출용 Playable Director의 enable를

false 처리해주었다

 

 

 

같은 Scene을 재생했지만

프롤로그를 보기 전과 후로

아주 잘 나뉜걸 확인했다!!

 

'Game Develop' 카테고리의 다른 글

퍼즐게임 디자인일지 - 13  (0) 2024.03.11
퍼즐게임 개발일지 - 18  (2) 2024.03.08
퍼즐게임 디자인일지 - 12  (0) 2024.03.07
퍼즐게임 개발일지 - 16  (0) 2024.03.05
퍼즐게임 개발일지 - 15  (0) 2024.03.04