new audio manager
This commit is contained in:
@@ -11182,7 +11182,7 @@ GameObject:
|
||||
- component: {fileID: 519420031}
|
||||
- component: {fileID: 519420033}
|
||||
- component: {fileID: 519420035}
|
||||
- component: {fileID: 519420034}
|
||||
- component: {fileID: 519420036}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
@@ -11281,102 +11281,6 @@ MonoBehaviour:
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
--- !u!82 &519420034
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: -8278190956376925970, guid: 833dc20f7f9e5b244a756827a43d874d, type: 2}
|
||||
m_audioClip: {fileID: 8300000, guid: 0b3a32694c5ed5f4fad733a3945a4249, type: 3}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 1
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!81 &519420035
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -11385,6 +11289,27 @@ AudioListener:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_Enabled: 1
|
||||
--- !u!114 &519420036
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc69655c5f792d9dab9db9dc72d26e93, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
audioMixer: {fileID: 24100000, guid: 833dc20f7f9e5b244a756827a43d874d, type: 2}
|
||||
sounds:
|
||||
- name: BackgroundMusic
|
||||
clip: {fileID: 8300000, guid: 0b3a32694c5ed5f4fad733a3945a4249, type: 3}
|
||||
volume: 1
|
||||
pitch: 1
|
||||
loop: 1
|
||||
source: {fileID: 0}
|
||||
outputMixer: {fileID: -8278190956376925970, guid: 833dc20f7f9e5b244a756827a43d874d, type: 2}
|
||||
--- !u!1 &525047094
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -4160,11 +4160,12 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 1386328419}
|
||||
- component: {fileID: 1386328418}
|
||||
- component: {fileID: 1386328417}
|
||||
- component: {fileID: 1386328422}
|
||||
- component: {fileID: 1386328426}
|
||||
- component: {fileID: 1386328425}
|
||||
- component: {fileID: 1386328423}
|
||||
- component: {fileID: 1386328426}
|
||||
- component: {fileID: 1386328417}
|
||||
- component: {fileID: 1386328427}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
@@ -4284,7 +4285,6 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
resolutionDropdown: {fileID: 415922102}
|
||||
mixer: {fileID: 24100000, guid: 833dc20f7f9e5b244a756827a43d874d, type: 2}
|
||||
--- !u!114 &1386328425
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4313,6 +4313,26 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: b0fa93b33fed1ce42a3e77548b03decc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1386328427
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1386328416}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc69655c5f792d9dab9db9dc72d26e93, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
audioMixer: {fileID: 24100000, guid: 833dc20f7f9e5b244a756827a43d874d, type: 2}
|
||||
sounds:
|
||||
- name: MenuMusic
|
||||
clip: {fileID: 8300000, guid: 0b3a32694c5ed5f4fad733a3945a4249, type: 3}
|
||||
volume: 1
|
||||
pitch: 1
|
||||
source: {fileID: 0}
|
||||
outputMixer: {fileID: -8278190956376925970, guid: 833dc20f7f9e5b244a756827a43d874d, type: 2}
|
||||
--- !u!1 &1421471717
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5591,8 +5611,8 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1386328423}
|
||||
m_TargetAssemblyTypeName: OptionMenu, Assembly-CSharp
|
||||
- m_Target: {fileID: 1386328427}
|
||||
m_TargetAssemblyTypeName: AudioManager, Assembly-CSharp
|
||||
m_MethodName: SetSfxVolume
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
@@ -6399,8 +6419,8 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1386328423}
|
||||
m_TargetAssemblyTypeName: OptionMenu, Assembly-CSharp
|
||||
- m_Target: {fileID: 1386328427}
|
||||
m_TargetAssemblyTypeName: AudioManager, Assembly-CSharp
|
||||
m_MethodName: SetMusicVolume
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
@@ -6638,8 +6658,8 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1386328423}
|
||||
m_TargetAssemblyTypeName: OptionMenu, Assembly-CSharp
|
||||
- m_Target: {fileID: 1386328427}
|
||||
m_TargetAssemblyTypeName: AudioManager, Assembly-CSharp
|
||||
m_MethodName: SetMainVolume
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
|
||||
39
Assets/Scripts/AudioManager.cs
Normal file
39
Assets/Scripts/AudioManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
public AudioMixer audioMixer;
|
||||
public Sound[] sounds;
|
||||
|
||||
private void Awake() {
|
||||
foreach(Sound s in sounds){
|
||||
s.source = gameObject.AddComponent<AudioSource>();
|
||||
s.source.clip = s.clip;
|
||||
|
||||
s.source.volume = s.volume;
|
||||
s.source.pitch = s.pitch;
|
||||
s.source.loop = s.loop;
|
||||
|
||||
s.source.outputAudioMixerGroup = s.outputMixer;
|
||||
}
|
||||
}
|
||||
|
||||
public void Play(string name){
|
||||
Sound s = Array.Find(sounds, sounds => sounds.name == name);
|
||||
s.source.Play();
|
||||
}
|
||||
|
||||
public void SetMainVolume(float mainVolume) {
|
||||
audioMixer.SetFloat("Master", mainVolume);
|
||||
}
|
||||
public void SetMusicVolume(float musicVolume) {
|
||||
audioMixer.SetFloat("Music", musicVolume);
|
||||
}
|
||||
public void SetSfxVolume(float sfxVolume) {
|
||||
audioMixer.SetFloat("Sfx", sfxVolume);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/AudioManager.cs.meta
Normal file
11
Assets/Scripts/AudioManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc69655c5f792d9dab9db9dc72d26e93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Scripts/Sound.cs
Normal file
19
Assets/Scripts/Sound.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
[System.Serializable]
|
||||
public class Sound
|
||||
{
|
||||
public string name;
|
||||
public AudioClip clip;
|
||||
[Range(0f, 1f)]
|
||||
public float volume;
|
||||
[Range(0.1f, 3f)]
|
||||
public float pitch;
|
||||
public bool loop;
|
||||
[HideInInspector]
|
||||
public AudioSource source;
|
||||
public AudioMixerGroup outputMixer;
|
||||
}
|
||||
11
Assets/Scripts/Sound.cs.meta
Normal file
11
Assets/Scripts/Sound.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bad3c18e1bd9a55da1a52c7588f21fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -36,6 +36,7 @@ public class jatekmanager : MonoBehaviour
|
||||
private TurnManager turnManager;
|
||||
private Source source;
|
||||
private vegpontozas vegpontozas;
|
||||
private AudioManager audioManager;
|
||||
|
||||
//ügynökcsapatok implementálása
|
||||
public TMP_Text[] oneone;
|
||||
@@ -64,6 +65,10 @@ public class jatekmanager : MonoBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
//hatterzene lejatszas
|
||||
audioManager = FindObjectOfType<AudioManager>();
|
||||
audioManager.Play("BackgroundMusic");
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
@@ -10,6 +10,16 @@ public class MainMenu : MonoBehaviour
|
||||
public GameObject CreditsMenuObj;
|
||||
public GameObject VideoButton;
|
||||
|
||||
private AudioManager audioManager;
|
||||
|
||||
private void Awake() {
|
||||
audioManager = FindObjectOfType<AudioManager>();
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
audioManager.Play("MenuMusic");
|
||||
}
|
||||
|
||||
public void PlayGame()
|
||||
{
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
|
||||
|
||||
@@ -38,19 +38,6 @@ public class OptionMenu : MonoBehaviour
|
||||
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
|
||||
}
|
||||
|
||||
//Audio
|
||||
public AudioMixer mixer;
|
||||
|
||||
public void SetMainVolume(float mainVolume) {
|
||||
mixer.SetFloat("Master", mainVolume);
|
||||
}
|
||||
public void SetMusicVolume(float musicVolume) {
|
||||
mixer.SetFloat("Music", musicVolume);
|
||||
}
|
||||
public void SetSfxVolume(float sfxVolume) {
|
||||
mixer.SetFloat("Sfx", sfxVolume);
|
||||
}
|
||||
|
||||
//Quality
|
||||
public void setQuality(int qualityIndex) {
|
||||
QualitySettings.SetQualityLevel(qualityIndex);
|
||||
|
||||
Reference in New Issue
Block a user