Audio
This commit is contained in:
@@ -2,28 +2,27 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using System;
|
||||
|
||||
public class Audiomanager : MonoBehaviour
|
||||
{
|
||||
public [] clips;
|
||||
public AudioSound[] clips;
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
foreach (AudioClip c in clips)
|
||||
foreach (AudioSound c in clips)
|
||||
{
|
||||
s.source = gameObject.AddComponent<AudionSource>();
|
||||
s.source.clip = s.clip;
|
||||
s.source.volume = s.volume;
|
||||
s.source.pitch = s.pitch;
|
||||
|
||||
|
||||
c.source = gameObject.AddComponent<AudionSource>();
|
||||
c.source.clip = c.clip;
|
||||
c.source.volume = c.volume;
|
||||
c.source.pitch = c.pitch;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Play(string name)
|
||||
{
|
||||
Sound s = Array.Find(clips, sound => sound.name == name);
|
||||
s.source.Play()
|
||||
AudioSound s = Array.Find(clips, sound => sound.name == name);
|
||||
s.source.Play();
|
||||
}
|
||||
}
|
||||
|
16
Assets/Scripts/AudioSound.cs
Normal file
16
Assets/Scripts/AudioSound.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
public class AudioSound
|
||||
{
|
||||
public string name;
|
||||
public AudioClip clip;
|
||||
|
||||
[Range(0f, 1f)]
|
||||
public float volume;
|
||||
[Range(.1f, 3f)]
|
||||
public float pitch;
|
||||
|
||||
[HideInInspector]
|
||||
public AudioSource source;
|
||||
}
|
11
Assets/Scripts/AudioSound.cs.meta
Normal file
11
Assets/Scripts/AudioSound.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd34753127bc0c44bb22ca73177fdd60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user