본문 바로가기
개발/C#

유니티 C# 오디오 Audio Source , Audio Clip 간단 사용법

by SPNK 2022. 7. 6.
반응형
  • 코드 작성
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Example : MonoBehaviour
{
    public AudioSource audioSource;

    public AudioClip audioClip;

    private void Start()
    {
        audioSource.Play(); //재생

        audioSource.Stop(); //정지

        audioSource.Pause(); //일시정지

        audioSource.UnPause(); //일시정지 해제

        audioSource.playOnAwake = true; //씬 시작시 바로 재생

        audioSource.loop = true; //반복 재생

        audioSource.mute = true; //음소거

        audioSource.volume = 1.0f; //볼륨 (0.0 ~ 1.0f)

        audioSource.PlayOneShot(audioClip, 1.0f); //특정 클립 한번 만 재생

        audioSource.clip = audioClip; //오디오 클립 교체

        if (audioSource.isPlaying) Debug.Log("오디오 재생중입니다."); //오디오 재생 여부 확인
    }
}

 


참고할만한 글

 

 

유니티 C# 구글 스프레드 시트 Google Sheet 간단 사용법

코드 작성 using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.Networking; public class Example : MonoBehaviour { const string DownloadURL = "https://docs.google.com/spreadsheets/d/" + "주

parksh3641.tistory.com

 

 

유니티 C# 자주 사용하는 연산자 Operator 모음

산술 연산자 using UnityEngine; public class Example : MonoBehaviour { public int a = 10; public int b = 5; void Awake() { //더하기 연산자 Debug.Log(a + b); // 15 //빼기 연산자 Debug.Log(a - b); // -5 //곱하기 연산자 Debug.Log(a * b);

parksh3641.tistory.com

 

반응형

댓글