-
1. 에디터 화면 Hieaechy에 gamedbject -> create empty 만들기고 soundmgr로 이름 정의.
2. soundmgr에 component -> Audio -> AudioSource
3. soundmgr.cs스크립트 연결
using UnityEngine;
using System.Collections;
public class soundmgr : MonoBehaviour {
public AudioClip ac;
AudioSource as;
public static soundmgr mgIstc;
void Awake() { if (soundmgr.mgIstc== null) { soundmgr.mgIstc = this; } //singleton pattern
void Start () { as = GetComponent<AudioSource>();}
public void playEx1() { as.PlayOneShot(ac); }
기타 3d sound로 값 설정 가능.
'Unity' 카테고리의 다른 글
Unity 무료 assets 사이트 (0) 2020.08.02 Unity - Scene 전환 (0) 2020.08.01 Unity - TextMesh(3D Text) (0) 2020.08.01 Unity - 기초 개념 (0) 2020.08.01 Unity - WebView (0) 2020.07.30 Unity - device camera, webcamtexture (0) 2018.02.07 Unity 변수 값 저장 불러오기 PlayerPrefs (0) 2018.01.08 Unity .dll .so 파일 위치 (0) 2017.11.03