Added audio to textboxes

This commit is contained in:
Zoe J
2022-02-22 07:31:48 -06:00
parent 4c7900d435
commit 78ba552c47
16 changed files with 728 additions and 59 deletions
File diff suppressed because one or more lines are too long
@@ -1,13 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour
{
{
public AudioMixer theMixer;
public Sound[] sounds;
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;
}
}
void Start()
{
if (PlayerPrefs.HasKey("MasterVol"))
@@ -23,4 +36,10 @@ public class AudioManager : MonoBehaviour
theMixer.SetFloat("SFXVol", PlayerPrefs.GetFloat("SFXVol"));
}
}
public void Play(string name)
{
Sound s = Array.Find(sounds, sounds => sounds.name == name);
s.source.Play();
}
}
@@ -0,0 +1,19 @@
using UnityEngine.Audio;
using UnityEngine;
[System.Serializable]
public class Sound
{
public string name;
public string output;
public AudioClip clip;
[Range(0f,1f)]
public float volume;
[Range(.1f,3f)]
public float pitch;
[HideInInspector]
public AudioSource source;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 37af6aa571006f94daeeabae711cbd44
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,52 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7572907803847010129
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7572907803847010131}
- component: {fileID: 7572907803847010130}
m_Layer: 0
m_Name: Audio Manager
m_TagString: AudioManager
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7572907803847010131
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7572907803847010129}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 965.77, y: 557.6189, z: -2532.9265}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7572907803847010130
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7572907803847010129}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ff8c6d62e5fc0f6478840a18add47f3a, type: 3}
m_Name:
m_EditorClassIdentifier:
theMixer: {fileID: 24100000, guid: c97f543260ac6cb409ed0760fe78c9a9, type: 2}
sounds:
- name: blip
clip: {fileID: 8300000, guid: 19f8faed41b1b3b49b4f52c1173ad212, type: 3}
volume: 1
pitch: 1
source: {fileID: 0}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b30f4c52408981c4c9fee33982f969d0
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+3 -1
View File
@@ -7,6 +7,7 @@ public class Dialogue : MonoBehaviour
{
public TMP_Text textbox;
public TMP_Text arrow;
public AudioManager audioManager;
public List<string> pages = new List<string>();
int curPage = 0;
public bool isOpen = true;
@@ -22,7 +23,7 @@ public class Dialogue : MonoBehaviour
// Start is called before the first frame update
void Start()
{
if(pages.Count > 0)
if (pages.Count > 0)
{
textbox.text = pages[0];
arrow.text = "";
@@ -84,6 +85,7 @@ public class Dialogue : MonoBehaviour
++cCount;
textbox.text = pages[curPage].Substring(0, cCount);
elapsed = 0;
audioManager.Play("blip");
}
//skip ahead
if(Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.DownArrow) ||
+197 -3
View File
@@ -173,7 +173,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1458967083
m_SortingLayer: 2
m_SortingLayer: 3
m_SortingOrder: 3
m_Sprite: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
@@ -300,7 +300,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1458967083
m_SortingLayer: 2
m_SortingLayer: 3
m_SortingOrder: 0
m_Sprite: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
@@ -672,7 +672,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1458967083
m_SortingLayer: 2
m_SortingLayer: 3
m_SortingOrder: 3
m_Sprite: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
@@ -694,6 +694,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 7059772333487008124}
- component: {fileID: -4250124882260964931}
- component: {fileID: -2532599903388458229}
m_Layer: 0
m_Name: Textbox
m_TagString: Untagged
@@ -717,3 +719,195 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &-4250124882260964931
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7059772333487008123}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: -7289459987239430450, guid: c97f543260ac6cb409ed0760fe78c9a9, type: 2}
m_audioClip: {fileID: 8300000, guid: 19f8faed41b1b3b49b4f52c1173ad212, type: 3}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
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!82 &-2532599903388458229
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7059772333487008123}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: -7289459987239430450, guid: c97f543260ac6cb409ed0760fe78c9a9, type: 2}
m_audioClip: {fileID: 8300000, guid: 5cc8ce95d298d884dbd32a9e81713bf1, type: 3}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
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
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 19f8faed41b1b3b49b4f52c1173ad212
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 5cc8ce95d298d884dbd32a9e81713bf1
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
+57 -44
View File
@@ -470,50 +470,6 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 816242365082533824, guid: 158e2c5bf8709994a87286eb92997cd6, type: 3}
m_PrefabInstance: {fileID: 97584711}
m_PrefabAsset: {fileID: 0}
--- !u!1 &100030749
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 100030751}
- component: {fileID: 100030750}
m_Layer: 0
m_Name: Audio Manager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &100030750
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 100030749}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ff8c6d62e5fc0f6478840a18add47f3a, type: 3}
m_Name:
m_EditorClassIdentifier:
theMixer: {fileID: 24100000, guid: c97f543260ac6cb409ed0760fe78c9a9, type: 2}
--- !u!4 &100030751
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 100030749}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 965.77, y: 557.6189, z: -2532.9265}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &150286900
GameObject:
m_ObjectHideFlags: 0
@@ -6138,3 +6094,60 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2138466855}
m_CullTransparentMesh: 1
--- !u!1001 &7572907803776646732
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 7572907803847010129, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_Name
value: Audio Manager
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_RootOrder
value: 5
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalPosition.x
value: 965.77
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalPosition.y
value: 557.6189
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalPosition.z
value: -2532.9265
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
+76 -1
View File
@@ -265,7 +265,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
controller: {fileID: 187176290}
animator: {fileID: 0}
runSpeed: 40
--- !u!1 &519420028
GameObject:
@@ -350,6 +349,17 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &789233146 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7572907803847010130, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
m_PrefabInstance: {fileID: 1187308619}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ff8c6d62e5fc0f6478840a18add47f3a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &978064013
GameObject:
m_ObjectHideFlags: 0
@@ -464,6 +474,63 @@ Transform:
m_Father: {fileID: 187176289}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1187308619
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 7572907803847010129, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_Name
value: Audio Manager
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalPosition.x
value: 965.77
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalPosition.y
value: 557.6189
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalPosition.z
value: -2532.9265
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7572907803847010131, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b30f4c52408981c4c9fee33982f969d0, type: 3}
--- !u!1 &1457467879
GameObject:
m_ObjectHideFlags: 0
@@ -794,6 +861,10 @@ PrefabInstance:
propertyPath: isOpen
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3758862681294202868, guid: 6ea336e93a8128346aad568255a7e6af, type: 3}
propertyPath: audioManager
value:
objectReference: {fileID: 789233146}
- target: {fileID: 3758862681294202868, guid: 6ea336e93a8128346aad568255a7e6af, type: 3}
propertyPath: pages.Array.size
value: 3
@@ -866,6 +937,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7395190149993767727, guid: 6ea336e93a8128346aad568255a7e6af, type: 3}
propertyPath: m_sharedMaterial
value:
objectReference: {fileID: -6507631187338287659, guid: 8bd1780577b8eaf43ad60554189eb11e, type: 2}
- target: {fileID: 8800572322419699558, guid: 6ea336e93a8128346aad568255a7e6af, type: 3}
propertyPath: m_LocalRotation.w
value: 0.6883546
+2 -1
View File
@@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- AudioManager
layers:
- Default
- TransparentFX
+2 -2
View File
@@ -12,13 +12,13 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c4b1505032b292926237e38271427fb
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
value: 22424703114646680e0b0227036c7d15181d116d3f6815332827187df7ee3d2cfb
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c6c1313191d7b623d28393930
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c7d15181d116d3f6815332827187df7ee3d2cfb
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650