모바일 겜이라서 그런가...


A 씬에서 메인 메뉴 버튼 클릭하면


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;


public class go_home : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{

}


// Update is called once per frame

void Update()

{

}


public void Gohome()

{

SceneManager.LoadScene("B");

}

}


이런 평범한 코드가 실행되고

B씬으로 전환됨


여기까지는 문제 없는데


문제는 그 다음에 B씬에서


시작 버튼을 클릭하면


using UnityEngine;

using UnityEngine.UI;

using UnityEngine.SceneManagement;


public class ButtonScript : MonoBehaviour

{

public GameObject targetObject; // 애니메이션 재생할 오브젝트임ㅇㅇ

private Animator animator; // 대상 오브젝트의 애니메이션 컴포넌트 ㅇㅇ


private void Start()

{

// 대상 오브젝트에서 애니메이터 컴포 가져오고

animator = targetObject.GetComponent<Animator>();

if (animator == null)

{

Debug.LogError("Animator component not found on the target object.");

}


// 처음에는 애니메이터 컴포 비활성화함

if (animator != null)

{

animator.enabled = false;

}

}


public void OnButtonClick()

{

if (meat_text.meat > 0){

if (animator != null)

{

animator.enabled = true;

meat_text.meat -= 1;

Invoke("ani_end", 0.55f);

}

}

}


public void ani_end()

{

animator.enabled = false;

SceneManager.LoadScene("A");

}

}


이런 지극히 평범하고 문제 없어보이는 코드를 실행하고

다시 A씬으로 넘어가게 되는데


A씬에서 아무것도 터치가 안먹히고 (스크립트, 오브젝트 다 활성화 되어있음)

몇몇 스크립트는 아예 작동 조차 안 하는데

또 대부분의 스크립트는 작동은 함


심지어 특정 스크립트에서 어떤 기능은 작동 하고 어떤 기능은 작동 안 함.


이게 진짜 이상한 이유가 뭐냐면


단순히 A씬을 언로드 했다가 다시 로드 하는 식으로 다시 불러오면

아무런 문제가 없이 수십번이고 할 수 있는데


저 과정만 수행하면 저렇게 근본없는 버그가 생긴다는 거임


이거 혹시 경험해본 사람 있음?



24b0d121e09c28a8699fe8b115ef046ecc48