Created
January 15, 2020 14:56
-
-
Save gremito/cbd571fe097074444a6bcacdbceaf387 to your computer and use it in GitHub Desktop.
複数ボイス再生スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class UnitychanVoice : MonoBehaviour | |
{ | |
private AudioSource audioSource; | |
[SerializeField] | |
private List<AudioClip> audioClipList = new List<AudioClip>(); | |
private int playId; | |
public int PlayId | |
{ | |
set { this.playId = value; } | |
} | |
void Start() | |
{ | |
playId = 0; | |
audioSource = gameObject.GetComponent<AudioSource>(); | |
} | |
void OnGUI() | |
{ | |
if(GUI.Button(new Rect(50, 300, 100, 100),"Voice Play")) | |
{ | |
VoicePlay(); | |
} | |
} | |
public void VoicePlay() | |
{ | |
audioSource.clip = audioClipList[playId]; | |
playId = (playId < audioClipList.Count-1) ? playId+1 : 0; | |
audioSource.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment