"깊이"가 다른 게임개발자 허민영

유저에서 게임까지, 철학에서 코딩까지, 본질을 보는 게임개발

내일배움캠프

[Unity 7기] TIL 9일차

허민영 2025. 1. 6. 17:03
  • 오늘의 학습진행
    • 강의 4주차 완료(프로젝트명: 르탄이를 찾아라)
  • 습득한 지식
    • 동시에 오디오 출력하기 audioSource.PlayOneShot(clip);
    public AudioClip busterSound;

    private void Awake()
    {
        myAudioSource = GetComponent<AudioSource>();
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Box"))
        {
            myAudioSource.PlayOneShot(busterSound);
        }
    }

https://docs.unity3d.com/kr/530/ScriptReference/AudioSource.PlayOneShot.html

 

 

  • 씬전환에도 오브젝트 유지하기 DontDestroyOnLoad()
DontDestroyOnLoad(gameObject);

https://docs.unity3d.com/kr/530/ScriptReference/Object.DontDestroyOnLoad.html

 

Object-DontDestroyOnLoad - Unity 스크립팅 API

Makes the object target not be destroyed automatically when loading a new scene.

docs.unity3d.com

 

'내일배움캠프' 카테고리의 다른 글

[Unity 7기] TIL 12일차  (1) 2025.01.09
[Unity 7기] TIL 10일차  (0) 2025.01.07
[Unity 7기] TIL 8일차  (0) 2025.01.03
[Unity 7기] TIL 7일차  (0) 2025.01.02
[Unity 7기] TIL 6일차  (1) 2024.12.31