728x90
using UnityEngine;
public class StartManager : MonoBehaviour
{
public static StartManager instance = null;
void Awake()
{
// SoundManager 인스턴스가 이미 있는지 확인, 이 상태로 설정
if (instance == null)
instance = this;
// 인스턴스가 이미 있는 경우 오브젝트 제거
else if (instance != this)
Destroy(gameObject);
// 이렇게 하면 다음 scene으로 넘어가도 오브젝트가 사라지지 않습니다.
DontDestroyOnLoad(gameObject);
}
}
728x90
반응형
'소프트웨어 개발 > 유니티(Unity)' 카테고리의 다른 글
[Unity] '' is an incorrect path for a scene file. BuildPlayer expects paths relative to the project folder. 오류 해결방법! (0) | 2021.11.09 |
---|---|
[Unity] 리스트 관련 함수 (0) | 2021.10.14 |
[Unity] 문자열 역순으로 출력 (0) | 2021.08.17 |
[Unity] Json에 저장된 한글 깨짐 현상 (0) | 2021.07.30 |
[Unity] 유니티 단축키 모음 (0) | 2021.07.26 |
댓글