Commit 92c81387 authored by Tommé Nöll's avatar Tommé Nöll
Browse files

added sound player for animation events

parent 6ac7c452
......@@ -19,10 +19,11 @@ GameObject:
- component: {fileID: 2336311380627323382}
- component: {fileID: 6210609790981217034}
- component: {fileID: 6675650529808371554}
- component: {fileID: 3000251011806316900}
- component: {fileID: 8874153887907557460}
- component: {fileID: 7195209752008871267}
- component: {fileID: 653927205334111538}
- component: {fileID: 3000251011806316900}
- component: {fileID: 3653103737125089714}
- component: {fileID: 2522563142084165191}
- component: {fileID: 1534784259788752579}
m_Layer: 9
......@@ -364,6 +365,28 @@ MonoBehaviour:
audioSource: {fileID: 2522563142084165191}
ropeShoot: {fileID: 8300000, guid: 0c1d1158031ec9c988324d4d9b065fe8, type: 3}
ropeSnap: {fileID: 8300000, guid: 67f31658b8bdf8ef1b9643b860021eea, type: 3}
--- !u!114 &3000251011806316900
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1534784259788752432}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d32ca477b490bae01b213f53f70d31fb, type: 3}
m_Name:
m_EditorClassIdentifier:
audioSource: {fileID: 8874153887907557460}
soundObjects:
- clip: {fileID: 8300000, guid: 32027f22574f422a1ae737a89fe953d2, type: 3}
soundOwner: {fileID: 3266308766096755421}
basedOn: 0
multiplier: 0.1
- clip: {fileID: 0}
soundOwner: {fileID: 6675650529808371554}
basedOn: 0
multiplier: 0.1
--- !u!82 &8874153887907557460
AudioSource:
m_ObjectHideFlags: 0
......@@ -649,7 +672,7 @@ PolygonCollider2D:
- {x: 0.043029785, y: -0.4945748}
- {x: 0.16046715, y: -0.45159277}
- {x: 0.19532919, y: -0.41465864}
--- !u!114 &3000251011806316900
--- !u!114 &3653103737125089714
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -658,19 +681,10 @@ MonoBehaviour:
m_GameObject: {fileID: 1534784259788752432}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d32ca477b490bae01b213f53f70d31fb, type: 3}
m_Script: {fileID: 11500000, guid: 8a70cf2fcd65961d89bbc7768271c472, type: 3}
m_Name:
m_EditorClassIdentifier:
audioSource: {fileID: 8874153887907557460}
soundObjects:
- clip: {fileID: 8300000, guid: 32027f22574f422a1ae737a89fe953d2, type: 3}
soundOwner: {fileID: 3266308766096755421}
basedOn: 0
multiplier: 0.1
- clip: {fileID: 0}
soundOwner: {fileID: 6675650529808371554}
basedOn: 0
multiplier: 0.1
audioSource: {fileID: 2522563142084165191}
--- !u!82 &2522563142084165191
AudioSource:
m_ObjectHideFlags: 0
......
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
[Serializable]
class SoundVolume
{
public AudioClip clip;
[Range(0f, 1f)]
public float volume;
}
public class SoundPlayer : MonoBehaviour
{
[SerializeField] private AudioSource audioSource;
[SerializeField] private SoundVolume[] soundVolumes;
void PlaySound(AudioClip clip)
{
float volume = 1.0f;
SoundVolume volumeObject = Array.Find(soundVolumes, element => element.clip == clip);
if (volumeObject != null)
{
volume = volumeObject.volume;
}
audioSource.PlayOneShot(clip, volume);
}
}
fileFormatVersion: 2
guid: 8a70cf2fcd65961d89bbc7768271c472
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment