Working experiment hooray
This commit is contained in:
parent
1097262dae
commit
750a314687
1443
Assets/FittsLawVR/Prefabs/Canvas.prefab
Normal file
1443
Assets/FittsLawVR/Prefabs/Canvas.prefab
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/FittsLawVR/Prefabs/Canvas.prefab.meta
Normal file
8
Assets/FittsLawVR/Prefabs/Canvas.prefab.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49f39d13b583ef54c853f20f5179b584
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39850532bc74a4078a24832112e8aef3
|
||||
timeCreated: 1534545520
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
@ -1,7 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc278786e6540af428ccbf7825495004
|
||||
timeCreated: 1500315262
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
9
Assets/Oculus/AudioManager.meta
Normal file
9
Assets/Oculus/AudioManager.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8bd6fc3bb11b734ebab29d20ce38dbe
|
||||
folderAsset: yes
|
||||
timeCreated: 1538788975
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Oculus/AudioManager/Audio.meta
Normal file
9
Assets/Oculus/AudioManager/Audio.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29ab7e927676ef74a93aeedf4146f1ac
|
||||
folderAsset: yes
|
||||
timeCreated: 1470780399
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Oculus/AudioManager/Audio/TestSounds.meta
Normal file
9
Assets/Oculus/AudioManager/Audio/TestSounds.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 180c8a539f95cce428f820b0ba392c1f
|
||||
folderAsset: yes
|
||||
timeCreated: 1468506676
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 485ac48a563e2bf44bb4de7ead5a1f68
|
||||
timeCreated: 1461716881
|
||||
licenseType: Store
|
||||
AudioImporter:
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3994560fb567c34a821fd9355c10eef
|
||||
timeCreated: 1461716882
|
||||
licenseType: Store
|
||||
AudioImporter:
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7000b4d67a1320940b363f3cf891dfff
|
||||
timeCreated: 1461716881
|
||||
licenseType: Store
|
||||
AudioImporter:
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8198ccc08475a764daaf226b841a55f1
|
||||
timeCreated: 1461716882
|
||||
licenseType: Store
|
||||
AudioImporter:
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Oculus/AudioManager/Scenes.meta
Normal file
9
Assets/Oculus/AudioManager/Scenes.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d597fe114807b54a99033a3dae9ce0d
|
||||
folderAsset: yes
|
||||
timeCreated: 1470780399
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Oculus/AudioManager/Scenes/Scripts.meta
Normal file
9
Assets/Oculus/AudioManager/Scenes/Scripts.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ee6cbebddf12044c95f9d6eb6e40823
|
||||
folderAsset: yes
|
||||
timeCreated: 1470780399
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
31
Assets/Oculus/AudioManager/Scenes/Scripts/TestScript.cs
Normal file
31
Assets/Oculus/AudioManager/Scenes/Scripts/TestScript.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class TestScript : MonoBehaviour {
|
||||
|
||||
[InspectorNote( "Sound Setup", "Press '1' to play testSound1 and '2' to play testSound2")]
|
||||
|
||||
public SoundFXRef testSound1;
|
||||
public SoundFXRef testSound2;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
// use attached game object location
|
||||
if ( Input.GetKeyDown( KeyCode.Alpha1 ) )
|
||||
{
|
||||
testSound1.PlaySoundAt( transform.position );
|
||||
}
|
||||
|
||||
// hard code information
|
||||
if ( Input.GetKeyDown( KeyCode.Alpha2 ) ) {
|
||||
testSound2.PlaySoundAt( new Vector3( 5.0f, 0.0f, 0.0f ) );
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Oculus/AudioManager/Scenes/Scripts/TestScript.cs.meta
Normal file
12
Assets/Oculus/AudioManager/Scenes/Scripts/TestScript.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfae243ecd01edd49bd439c56a8b18cf
|
||||
timeCreated: 1468506975
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
434
Assets/Oculus/AudioManager/Scenes/Test.unity
Normal file
434
Assets/Oculus/AudioManager/Scenes/Test.unity
Normal file
@ -0,0 +1,434 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 8
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 3
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_TemporalCoherenceThreshold: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 0
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 8
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_TextureWidth: 1024
|
||||
m_TextureHeight: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 1
|
||||
m_BakeBackend: 0
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_ShadowMaskMode: 2
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &767466533
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 767466535}
|
||||
- component: {fileID: 767466534}
|
||||
m_Layer: 0
|
||||
m_Name: AudioManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &767466534
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 767466533}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6d1d30b41806244fca035fdae2896fb7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
makePersistent: 1
|
||||
enableSpatializedAudio: 1
|
||||
enableSpatializedFastOverride: 0
|
||||
audioMixer: {fileID: 0}
|
||||
defaultMixerGroup: {fileID: 24300001, guid: 323417d454569d94fa01d511f6eb44d9, type: 2}
|
||||
reservedMixerGroup: {fileID: 0}
|
||||
voiceChatMixerGroup: {fileID: 0}
|
||||
verboseLogging: 0
|
||||
maxSoundEmitters: 32
|
||||
volumeSoundFX: 1
|
||||
soundFxFadeSecs: 1
|
||||
audioMinFallOffDistance: 1
|
||||
audioMaxFallOffDistance: 25
|
||||
soundGroupings:
|
||||
- name: Test Group
|
||||
soundList:
|
||||
- name: TestSound1
|
||||
playback: 0
|
||||
volume: 1
|
||||
pitchVariance: {x: 0.95, y: 1.05}
|
||||
falloffDistance: {x: 1, y: 25}
|
||||
falloffCurve: 2
|
||||
volumeFalloffCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 1.0044228
|
||||
inSlope: -1.9459304
|
||||
outSlope: -1.9459304
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 0.27001944
|
||||
value: 0.24837627
|
||||
inSlope: -1.3226271
|
||||
outSlope: -1.3226271
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 0.99744946
|
||||
value: -0.0020017216
|
||||
inSlope: -0.42040923
|
||||
outSlope: -0.42040923
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 0
|
||||
reverbZoneMix:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 1.0044228
|
||||
inSlope: -1.9459304
|
||||
outSlope: -1.9459304
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 0.36357749
|
||||
value: 0.4567863
|
||||
inSlope: -1.3226271
|
||||
outSlope: -1.3226271
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 0.99594045
|
||||
value: 0.19572063
|
||||
inSlope: -0.107312
|
||||
outSlope: -0.107312
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 0
|
||||
spread: 0
|
||||
pctChanceToPlay: 1
|
||||
priority: 0
|
||||
delay: {x: 0, y: 0}
|
||||
looping: 0
|
||||
ospProps:
|
||||
enableSpatialization: 1
|
||||
useFastOverride: 1
|
||||
gain: 0
|
||||
enableInvSquare: 1
|
||||
volumetric: 0
|
||||
invSquareFalloff: {x: 1, y: 250}
|
||||
soundClips:
|
||||
- {fileID: 8300000, guid: 7000b4d67a1320940b363f3cf891dfff, type: 3}
|
||||
- {fileID: 8300000, guid: 8198ccc08475a764daaf226b841a55f1, type: 3}
|
||||
visibilityToggle: 0
|
||||
- name: TestSound2
|
||||
playback: 0
|
||||
volume: 1
|
||||
pitchVariance: {x: 0.79999995, y: 1.25}
|
||||
falloffDistance: {x: 1, y: 25}
|
||||
falloffCurve: 1
|
||||
volumeFalloffCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMix:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spread: 0
|
||||
pctChanceToPlay: 1
|
||||
priority: 0
|
||||
delay: {x: 0, y: 0}
|
||||
looping: 0
|
||||
ospProps:
|
||||
enableSpatialization: 1
|
||||
useFastOverride: 0
|
||||
gain: 0
|
||||
enableInvSquare: 0
|
||||
volumetric: 0
|
||||
invSquareFalloff: {x: 1, y: 25}
|
||||
soundClips:
|
||||
- {fileID: 8300000, guid: 485ac48a563e2bf44bb4de7ead5a1f68, type: 3}
|
||||
- {fileID: 8300000, guid: d3994560fb567c34a821fd9355c10eef, type: 3}
|
||||
visibilityToggle: 0
|
||||
mixerGroup: {fileID: 24300001, guid: 1dd706bb85d8aef4e83a6229dbd62c36, type: 2}
|
||||
maxPlayingSounds: 0
|
||||
preloadAudio: 0
|
||||
volumeOverride: 1
|
||||
playingSoundCount: 0
|
||||
--- !u!4 &767466535
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 767466533}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1050355579
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1050355581}
|
||||
- component: {fileID: 1050355580}
|
||||
m_Layer: 0
|
||||
m_Name: TestScript
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1050355580
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1050355579}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cfae243ecd01edd49bd439c56a8b18cf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
testSound1:
|
||||
soundFXName: TestSound1
|
||||
testSound2:
|
||||
soundFXName: TestSound2
|
||||
--- !u!4 &1050355581
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1050355579}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2106254871
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 2106254876}
|
||||
- component: {fileID: 2106254875}
|
||||
- component: {fileID: 2106254874}
|
||||
- component: {fileID: 2106254873}
|
||||
- component: {fileID: 2106254872}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &2106254872
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 2106254871}
|
||||
m_Enabled: 1
|
||||
--- !u!124 &2106254873
|
||||
Behaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 2106254871}
|
||||
m_Enabled: 1
|
||||
--- !u!92 &2106254874
|
||||
Behaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 2106254871}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &2106254875
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 2106254871}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 1
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 0
|
||||
m_AllowMSAA: 1
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
m_StereoMirrorMode: 0
|
||||
--- !u!4 &2106254876
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 2106254871}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -10}
|
||||
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}
|
8
Assets/Oculus/AudioManager/Scenes/Test.unity.meta
Normal file
8
Assets/Oculus/AudioManager/Scenes/Test.unity.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 600e5d49b0a68254286400e32c53addc
|
||||
timeCreated: 1468506358
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Oculus/AudioManager/Scripts.meta
Normal file
9
Assets/Oculus/AudioManager/Scripts.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25be027379f7fce4d97ba2bcaf313019
|
||||
folderAsset: yes
|
||||
timeCreated: 1470780399
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Oculus/AudioManager/Scripts/Audio.meta
Normal file
9
Assets/Oculus/AudioManager/Scripts/Audio.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8c0d722519c64144a78f8fc99cd40b5
|
||||
folderAsset: yes
|
||||
timeCreated: 1468505670
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
113
Assets/Oculus/AudioManager/Scripts/Audio/AmbienceEmitter.cs
Normal file
113
Assets/Oculus/AudioManager/Scripts/Audio/AmbienceEmitter.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
|
||||
AmbienceEmitter()
|
||||
|
||||
-----------------------
|
||||
*/
|
||||
public class AmbienceEmitter : MonoBehaviour {
|
||||
|
||||
public SoundFXRef[] ambientSounds = new SoundFXRef[0];
|
||||
public bool autoActivate = true;
|
||||
[Tooltip("Automatically play the sound randomly again when checked. Should be OFF for looping sounds")]
|
||||
public bool autoRetrigger = true;
|
||||
[MinMax( 2.0f, 4.0f, 0.1f, 10.0f )]
|
||||
public Vector2 randomRetriggerDelaySecs = new Vector2( 2.0f, 4.0f );
|
||||
[Tooltip( "If defined, the sounds will randomly play from these transform positions, otherwise the sound will play from this transform" )]
|
||||
public Transform[] playPositions = new Transform[0];
|
||||
private bool activated = false;
|
||||
private int playingIdx = -1;
|
||||
private float nextPlayTime = 0.0f;
|
||||
private float fadeTime = 0.25f;
|
||||
private int lastPosIdx = -1;
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Awake()
|
||||
-----------------------
|
||||
*/
|
||||
void Awake() {
|
||||
if ( autoActivate ) {
|
||||
activated = true;
|
||||
nextPlayTime = Time.time + Random.Range( randomRetriggerDelaySecs.x, randomRetriggerDelaySecs.y );
|
||||
}
|
||||
// verify all the play positions are valid
|
||||
foreach ( Transform t in playPositions ) {
|
||||
if ( t == null ) {
|
||||
Debug.LogWarning( "[AmbienceEmitter] Invalid play positions in " + name );
|
||||
playPositions = new Transform[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Update()
|
||||
-----------------------
|
||||
*/
|
||||
void Update() {
|
||||
if ( activated ) {
|
||||
if ( ( playingIdx == -1 ) || autoRetrigger ) {
|
||||
if ( Time.time >= nextPlayTime ) {
|
||||
Play();
|
||||
if ( !autoRetrigger ) {
|
||||
activated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
OnTriggerEnter()
|
||||
-----------------------
|
||||
*/
|
||||
public void OnTriggerEnter( Collider col ) {
|
||||
activated = !activated;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Play()
|
||||
-----------------------
|
||||
*/
|
||||
public void Play() {
|
||||
Transform transformToPlayFrom = transform;
|
||||
if ( playPositions.Length > 0 ) {
|
||||
int idx = Random.Range( 0, playPositions.Length );
|
||||
while ( ( playPositions.Length > 1 ) && ( idx == lastPosIdx ) ) {
|
||||
idx = Random.Range( 0, playPositions.Length );
|
||||
}
|
||||
transformToPlayFrom = playPositions[idx];
|
||||
lastPosIdx = idx;
|
||||
}
|
||||
playingIdx = ambientSounds[Random.Range(0, ambientSounds.Length)].PlaySoundAt( transformToPlayFrom.position );
|
||||
if ( playingIdx != -1 ) {
|
||||
AudioManager.FadeInSound( playingIdx, fadeTime );
|
||||
nextPlayTime = Time.time + Random.Range( randomRetriggerDelaySecs.x, randomRetriggerDelaySecs.y );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
EnableEmitter()
|
||||
-----------------------
|
||||
*/
|
||||
public void EnableEmitter( bool enable ) {
|
||||
activated = enable;
|
||||
if ( enable ) {
|
||||
Play();
|
||||
} else {
|
||||
if ( playingIdx != -1 ) {
|
||||
AudioManager.FadeOutSound( playingIdx, fadeTime );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c11944691f6b9cf44a391c95cb3f7dea
|
||||
timeCreated: 1455050294
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
425
Assets/Oculus/AudioManager/Scripts/Audio/AudioManager.cs
Normal file
425
Assets/Oculus/AudioManager/Scripts/Audio/AudioManager.cs
Normal file
@ -0,0 +1,425 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
#endif
|
||||
|
||||
public enum PreloadSounds {
|
||||
Default, // default unity behavior
|
||||
Preload, // audio clips are forced to preload
|
||||
ManualPreload, // audio clips are forced to not preload, preloading must be done manually
|
||||
}
|
||||
|
||||
public enum Fade
|
||||
{
|
||||
In,
|
||||
Out
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SoundGroup {
|
||||
public SoundGroup( string name ) {
|
||||
this.name = name;
|
||||
}
|
||||
public SoundGroup() {
|
||||
mixerGroup = null;
|
||||
maxPlayingSounds = 0;
|
||||
preloadAudio = PreloadSounds.Default;
|
||||
volumeOverride = 1.0f;
|
||||
}
|
||||
public void IncrementPlayCount() {
|
||||
playingSoundCount = Mathf.Clamp( ++playingSoundCount, 0, maxPlayingSounds );
|
||||
}
|
||||
public void DecrementPlayCount() {
|
||||
playingSoundCount = Mathf.Clamp( --playingSoundCount, 0, maxPlayingSounds );
|
||||
}
|
||||
public bool CanPlaySound() {
|
||||
return ( maxPlayingSounds == 0 ) || ( playingSoundCount < maxPlayingSounds );
|
||||
}
|
||||
|
||||
public string name = string.Empty;
|
||||
public SoundFX[] soundList = new SoundFX[0];
|
||||
public AudioMixerGroup mixerGroup = null; // default = AudioManager.defaultMixerGroup
|
||||
[Range(0,64)]
|
||||
public int maxPlayingSounds = 0; // default = 0, unlimited
|
||||
// TODO: this preload behavior is not yet implemented
|
||||
public PreloadSounds preloadAudio = PreloadSounds.Default; // default = true, audio clip data will be preloaded
|
||||
public float volumeOverride = 1.0f; // default = 1.0
|
||||
|
||||
[HideInInspector]
|
||||
public int playingSoundCount = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
|
||||
AudioManager
|
||||
|
||||
-----------------------
|
||||
*/
|
||||
public partial class AudioManager : MonoBehaviour {
|
||||
|
||||
[Tooltip("Make the audio manager persistent across all scene loads")]
|
||||
public bool makePersistent = true; // true = don't destroy on load
|
||||
[Tooltip("Enable the OSP audio plugin features")]
|
||||
public bool enableSpatializedAudio = true; // true = enable spatialized audio
|
||||
[Tooltip("Always play spatialized sounds with no reflections (Default)")]
|
||||
public bool enableSpatializedFastOverride = false; // true = disable spatialized reflections override
|
||||
[Tooltip("The audio mixer asset used for snapshot blends, etc.")]
|
||||
public AudioMixer audioMixer = null;
|
||||
[Tooltip( "The audio mixer group used for the pooled emitters" )]
|
||||
public AudioMixerGroup defaultMixerGroup = null;
|
||||
[Tooltip( "The audio mixer group used for the reserved pool emitter" )]
|
||||
public AudioMixerGroup reservedMixerGroup = null;
|
||||
[Tooltip( "The audio mixer group used for voice chat" )]
|
||||
public AudioMixerGroup voiceChatMixerGroup = null;
|
||||
[Tooltip("Log all PlaySound calls to the Unity console")]
|
||||
public bool verboseLogging = false; // true = log all PlaySounds
|
||||
[Tooltip("Maximum sound emitters")]
|
||||
public int maxSoundEmitters = 32; // total number of sound emitters created
|
||||
[Tooltip("Default volume for all sounds modulated by individual sound FX volumes")]
|
||||
public float volumeSoundFX = 1.0f; // user pref: volume of all sound FX
|
||||
[Tooltip("Sound FX fade time")]
|
||||
public float soundFxFadeSecs = 1.0f; // sound FX fade time
|
||||
|
||||
public float audioMinFallOffDistance = 1.0f; // minimum falloff distance
|
||||
public float audioMaxFallOffDistance = 25.0f; // maximum falloff distance
|
||||
|
||||
public SoundGroup[] soundGroupings = new SoundGroup[0];
|
||||
|
||||
private Dictionary<string,SoundFX> soundFXCache = null;
|
||||
|
||||
static private AudioManager theAudioManager = null;
|
||||
static private FastList<string> names = new FastList<string>();
|
||||
static private string[] defaultSound = new string[1] { "Default Sound" };
|
||||
static private SoundFX nullSound = new SoundFX();
|
||||
static private bool hideWarnings = false;
|
||||
static public bool enableSpatialization { get { return ( theAudioManager !=null ) ? theAudioManager.enableSpatializedAudio : false; } }
|
||||
|
||||
static public AudioManager Instance { get { return theAudioManager; } }
|
||||
static public float NearFallOff { get { return theAudioManager.audioMinFallOffDistance; } }
|
||||
static public float FarFallOff { get { return theAudioManager.audioMaxFallOffDistance; } }
|
||||
static public AudioMixerGroup EmitterGroup { get { return theAudioManager.defaultMixerGroup; } }
|
||||
static public AudioMixerGroup ReservedGroup { get { return theAudioManager.reservedMixerGroup; } }
|
||||
static public AudioMixerGroup VoipGroup { get { return theAudioManager.voiceChatMixerGroup; } }
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Awake()
|
||||
-----------------------
|
||||
*/
|
||||
void Awake() {
|
||||
Init();
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
OnDestroy()
|
||||
-----------------------
|
||||
*/
|
||||
void OnDestroy() {
|
||||
// we only want the initialized audio manager instance cleaning up the sound emitters
|
||||
if ( theAudioManager == this ) {
|
||||
if ( soundEmitterParent != null ) {
|
||||
Destroy( soundEmitterParent );
|
||||
}
|
||||
}
|
||||
///TODO - if you change scenes you'll want to call OnPreSceneLoad to detach the sound emitters
|
||||
///from anything they might be parented to or they will get destroyed with that object
|
||||
///there should only be one instance of the AudioManager across the life of the game/app
|
||||
///GameManager.OnPreSceneLoad -= OnPreSceneLoad;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Init()
|
||||
-----------------------
|
||||
*/
|
||||
void Init() {
|
||||
if ( theAudioManager != null ) {
|
||||
if ( Application.isPlaying && ( theAudioManager != this ) ) {
|
||||
enabled = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
theAudioManager = this;
|
||||
|
||||
///TODO - if you change scenes you'll want to call OnPreSceneLoad to detach the sound emitters
|
||||
///from anything they might be parented to or they will get destroyed with that object
|
||||
///there should only be one instance of the AudioManager across the life of the game/app
|
||||
///GameManager.OnPreSceneLoad += OnPreSceneLoad;
|
||||
|
||||
// make sure the first one is a null sound
|
||||
nullSound.name = "Default Sound";
|
||||
|
||||
// build the sound FX cache
|
||||
RebuildSoundFXCache();
|
||||
|
||||
// create the sound emitters
|
||||
if ( Application.isPlaying ) {
|
||||
InitializeSoundSystem();
|
||||
if ( makePersistent && ( transform.parent == null ) ) {
|
||||
// don't destroy the audio manager on scene loads
|
||||
DontDestroyOnLoad( gameObject );
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log( "[AudioManager] Initialized..." );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Update()
|
||||
-----------------------
|
||||
*/
|
||||
void Update() {
|
||||
// update the free and playing lists
|
||||
UpdateFreeEmitters();
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
RebuildSoundFXCache()
|
||||
-----------------------
|
||||
*/
|
||||
void RebuildSoundFXCache() {
|
||||
// build the SoundFX dictionary for quick name lookups
|
||||
int count = 0;
|
||||
for ( int group = 0; group < soundGroupings.Length; group++ ) {
|
||||
count += soundGroupings[group].soundList.Length;
|
||||
}
|
||||
soundFXCache = new Dictionary<string,SoundFX>( count + 1 );
|
||||
// add the null sound
|
||||
soundFXCache.Add( nullSound.name, nullSound );
|
||||
// add the rest
|
||||
for ( int group = 0; group < soundGroupings.Length; group++ ) {
|
||||
for ( int i = 0; i < soundGroupings[group].soundList.Length; i++ ) {
|
||||
if ( soundFXCache.ContainsKey( soundGroupings[group].soundList[i].name ) ) {
|
||||
Debug.LogError( "ERROR: Duplicate Sound FX name in the audio manager: '" + soundGroupings[group].name + "' > '" + soundGroupings[group].soundList[i].name + "'" );
|
||||
} else {
|
||||
soundGroupings[group].soundList[i].Group = soundGroupings[group];
|
||||
soundFXCache.Add( soundGroupings[group].soundList[i].name, soundGroupings[group].soundList[i] );
|
||||
}
|
||||
}
|
||||
soundGroupings[group].playingSoundCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
FindSoundFX()
|
||||
-----------------------
|
||||
*/
|
||||
static public SoundFX FindSoundFX( string name, bool rebuildCache = false ) {
|
||||
#if UNITY_EDITOR
|
||||
if ( theAudioManager == null ) {
|
||||
Debug.LogError( "ERROR: audio manager not yet initialized or created!" + " Time: " + Time.time );
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
if ( string.IsNullOrEmpty( name ) ) {
|
||||
return nullSound;
|
||||
}
|
||||
if ( rebuildCache ) {
|
||||
theAudioManager.RebuildSoundFXCache();
|
||||
}
|
||||
if ( !theAudioManager.soundFXCache.ContainsKey( name ) ) {
|
||||
#if DEBUG_BUILD || UNITY_EDITOR
|
||||
Debug.LogError( "WARNING: Missing Sound FX in cache: " + name );
|
||||
#endif
|
||||
return nullSound;
|
||||
}
|
||||
return theAudioManager.soundFXCache[name];
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
FindAudioManager()
|
||||
-----------------------
|
||||
*/
|
||||
static private bool FindAudioManager() {
|
||||
GameObject audioManagerObject = GameObject.Find( "AudioManager" );
|
||||
if ( ( audioManagerObject == null ) || ( audioManagerObject.GetComponent<AudioManager>() == null ) ) {
|
||||
if ( !hideWarnings ) {
|
||||
Debug.LogError( "[ERROR] AudioManager object missing from hierarchy!" );
|
||||
hideWarnings = true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
audioManagerObject.GetComponent<AudioManager>().Init();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
GetGameObject()
|
||||
-----------------------
|
||||
*/
|
||||
static public GameObject GetGameObject() {
|
||||
if ( theAudioManager == null ) {
|
||||
if ( !FindAudioManager() ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return theAudioManager.gameObject;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
NameMinusGroup()
|
||||
strip off the sound group from the inspector dropdown
|
||||
-----------------------
|
||||
*/
|
||||
static public string NameMinusGroup( string name ) {
|
||||
if ( name.IndexOf( "/" ) > -1 ) {
|
||||
return name.Substring( name.IndexOf( "/" ) + 1 );
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
GetSoundFXNames()
|
||||
used by the inspector
|
||||
-----------------------
|
||||
*/
|
||||
static public string[] GetSoundFXNames( string currentValue, out int currentIdx ) {
|
||||
currentIdx = 0;
|
||||
names.Clear();
|
||||
if ( theAudioManager == null ) {
|
||||
if ( !FindAudioManager() ) {
|
||||
return defaultSound;
|
||||
}
|
||||
}
|
||||
names.Add( nullSound.name );
|
||||
for ( int group = 0; group < theAudioManager.soundGroupings.Length; group++ ) {
|
||||
for ( int i = 0; i < theAudioManager.soundGroupings[group].soundList.Length; i++ ) {
|
||||
if ( string.Compare( currentValue, theAudioManager.soundGroupings[group].soundList[i].name, true ) == 0 ) {
|
||||
currentIdx = names.Count;
|
||||
}
|
||||
names.Add( theAudioManager.soundGroupings[group].name + "/" + theAudioManager.soundGroupings[group].soundList[i].name );
|
||||
}
|
||||
}
|
||||
//names.Sort( delegate( string s1, string s2 ) { return s1.CompareTo( s2 ); } );
|
||||
return names.ToArray();
|
||||
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
/*
|
||||
-----------------------
|
||||
OnPrefabReimported()
|
||||
-----------------------
|
||||
*/
|
||||
static public void OnPrefabReimported() {
|
||||
if ( theAudioManager != null ) {
|
||||
Debug.Log( "[AudioManager] Reimporting the sound FX cache." );
|
||||
theAudioManager.RebuildSoundFXCache();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
PlaySound()
|
||||
used in the editor
|
||||
-----------------------
|
||||
*/
|
||||
static public void PlaySound( string soundFxName ) {
|
||||
if ( theAudioManager == null ) {
|
||||
if ( !FindAudioManager() ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
SoundFX soundFX = FindSoundFX( soundFxName, true );
|
||||
if ( soundFX == null ) {
|
||||
return;
|
||||
}
|
||||
AudioClip clip = soundFX.GetClip();
|
||||
if ( clip != null ) {
|
||||
Assembly unityEditorAssembly = typeof(AudioImporter).Assembly;
|
||||
Type audioUtilClass = unityEditorAssembly.GetType("UnityEditor.AudioUtil");
|
||||
MethodInfo method = audioUtilClass.GetMethod(
|
||||
"PlayClip",
|
||||
BindingFlags.Static | BindingFlags.Public,
|
||||
null,
|
||||
new System.Type[] { typeof(AudioClip) },
|
||||
null );
|
||||
method.Invoke( null, new object[] { clip } );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
IsSoundPlaying()
|
||||
used in the editor
|
||||
-----------------------
|
||||
*/
|
||||
static public bool IsSoundPlaying( string soundFxName ) {
|
||||
if ( theAudioManager == null ) {
|
||||
if ( !FindAudioManager() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
SoundFX soundFX = FindSoundFX( soundFxName, true );
|
||||
if ( soundFX == null ) {
|
||||
return false;
|
||||
}
|
||||
AudioClip clip = soundFX.GetClip();
|
||||
if ( clip != null ) {
|
||||
Assembly unityEditorAssembly = typeof(AudioImporter).Assembly;
|
||||
Type audioUtilClass = unityEditorAssembly.GetType("UnityEditor.AudioUtil");
|
||||
MethodInfo method = audioUtilClass.GetMethod(
|
||||
"IsClipPlaying",
|
||||
BindingFlags.Static | BindingFlags.Public,
|
||||
null,
|
||||
new System.Type[] { typeof(AudioClip) },
|
||||
null );
|
||||
return Convert.ToBoolean( method.Invoke( null, new object[] { clip } ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
StopSound()
|
||||
used in the editor
|
||||
-----------------------
|
||||
*/
|
||||
static public void StopSound(string soundFxName)
|
||||
{
|
||||
if (theAudioManager == null)
|
||||
{
|
||||
if (!FindAudioManager())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
SoundFX soundFX = FindSoundFX(soundFxName, true);
|
||||
if (soundFX == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AudioClip clip = soundFX.GetClip();
|
||||
if (clip != null)
|
||||
{
|
||||
Assembly unityEditorAssembly = typeof(AudioImporter).Assembly;
|
||||
Type audioUtilClass = unityEditorAssembly.GetType("UnityEditor.AudioUtil");
|
||||
MethodInfo method = audioUtilClass.GetMethod(
|
||||
"StopClip",
|
||||
BindingFlags.Static | BindingFlags.Public,
|
||||
null,
|
||||
new System.Type[] { typeof(AudioClip) },
|
||||
null);
|
||||
method.Invoke(null, new object[] { clip });
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d1d30b41806244fca035fdae2896fb7
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
782
Assets/Oculus/AudioManager/Scripts/Audio/AudioManager_Sound.cs
Normal file
782
Assets/Oculus/AudioManager/Scripts/Audio/AudioManager_Sound.cs
Normal file
@ -0,0 +1,782 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Types
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
public enum EmitterChannel {
|
||||
None = -1,
|
||||
Reserved = 0, // plays on the single reserved emitter
|
||||
Any // queues to the next available emitter
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MixerSnapshot {
|
||||
public AudioMixerSnapshot snapshot = null;
|
||||
public float transitionTime = 0.25f;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
|
||||
GameManager Sound Routines
|
||||
|
||||
-----------------------
|
||||
*/
|
||||
public partial class AudioManager : MonoBehaviour {
|
||||
|
||||
public enum Fade {
|
||||
In,
|
||||
Out
|
||||
}
|
||||
|
||||
private float audioMaxFallOffDistanceSqr = 25.0f * 25.0f; // past this distance, sounds are ignored for the local player
|
||||
|
||||
private SoundEmitter[] soundEmitters = null; // pool of sound emitters to play sounds through
|
||||
|
||||
private FastList<SoundEmitter> playingEmitters = new FastList<SoundEmitter>();
|
||||
private FastList<SoundEmitter> nextFreeEmitters = new FastList<SoundEmitter>();
|
||||
|
||||
private MixerSnapshot currentSnapshot = null;
|
||||
|
||||
static private GameObject soundEmitterParent = null; // parent object for the sound emitters
|
||||
static private Transform staticListenerPosition = null; // play position for regular 2D sounds
|
||||
|
||||
static private bool showPlayingEmitterCount = false;
|
||||
static private bool forceShowEmitterCount = false;
|
||||
|
||||
static private bool soundEnabled = true;
|
||||
static public bool SoundEnabled { get { return soundEnabled; } }
|
||||
|
||||
static readonly AnimationCurve defaultReverbZoneMix = new AnimationCurve( new Keyframe[2] { new Keyframe( 0f, 1.0f ), new Keyframe( 1f, 1f ) } );
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
InitializeSoundSystem()
|
||||
initialize persistent sound emitter objects that live across scene loads
|
||||
-----------------------
|
||||
*/
|
||||
void InitializeSoundSystem() {
|
||||
|
||||
int bufferLength = 960;
|
||||
int numBuffers = 4;
|
||||
AudioSettings.GetDSPBufferSize( out bufferLength, out numBuffers );
|
||||
if ( Application.isPlaying ) {
|
||||
Debug.Log( "[AudioManager] Audio Sample Rate: " + AudioSettings.outputSampleRate );
|
||||
Debug.Log( "[AudioManager] Audio Buffer Length: " + bufferLength + " Size: " + numBuffers );
|
||||
}
|
||||
|
||||
// find the audio listener for playing regular 2D sounds
|
||||
AudioListener audioListenerObject = GameObject.FindObjectOfType<AudioListener>() as AudioListener;
|
||||
if ( audioListenerObject == null ) {
|
||||
Debug.LogError( "[AudioManager] Missing AudioListener object! Add one to the scene." );
|
||||
} else {
|
||||
staticListenerPosition = audioListenerObject.transform;
|
||||
}
|
||||
|
||||
// we allocate maxSoundEmitters + reserved channels
|
||||
soundEmitters = new SoundEmitter[maxSoundEmitters+(int)EmitterChannel.Any];
|
||||
|
||||
// see if the sound emitters have already been created, if so, nuke it, it shouldn't exist in the scene upon load
|
||||
soundEmitterParent = GameObject.Find( "__SoundEmitters__" );
|
||||
if ( soundEmitterParent != null ) {
|
||||
// delete any sound emitters hanging around
|
||||
Destroy( soundEmitterParent );
|
||||
}
|
||||
|
||||
// create them all
|
||||
soundEmitterParent = new GameObject( "__SoundEmitters__" );
|
||||
for ( int i = 0; i < maxSoundEmitters + (int)EmitterChannel.Any; i++ ) {
|
||||
GameObject emitterObject = new GameObject( "SoundEmitter_" + i );
|
||||
emitterObject.transform.parent = soundEmitterParent.transform;
|
||||
emitterObject.transform.position = Vector3.zero;
|
||||
// don't ever save this to the scene
|
||||
emitterObject.hideFlags = HideFlags.DontSaveInEditor;
|
||||
// add the sound emitter components
|
||||
soundEmitters[i] = emitterObject.AddComponent<SoundEmitter>();
|
||||
soundEmitters[i].SetDefaultParent( soundEmitterParent.transform );
|
||||
soundEmitters[i].SetChannel( i );
|
||||
soundEmitters[i].Stop();
|
||||
// save off the original index
|
||||
soundEmitters[i].originalIdx = i;
|
||||
}
|
||||
// reset the free emitter lists
|
||||
ResetFreeEmitters();
|
||||
soundEmitterParent.hideFlags = HideFlags.DontSaveInEditor;
|
||||
|
||||
audioMaxFallOffDistanceSqr = audioMaxFallOffDistance * audioMaxFallOffDistance;
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
UpdateFreeEmitters()
|
||||
-----------------------
|
||||
*/
|
||||
void UpdateFreeEmitters() {
|
||||
if ( verboseLogging ) {
|
||||
if ( Input.GetKeyDown( KeyCode.A ) ) {
|
||||
forceShowEmitterCount = !forceShowEmitterCount;
|
||||
}
|
||||
if ( forceShowEmitterCount ) {
|
||||
showPlayingEmitterCount = true;
|
||||
}
|
||||
}
|
||||
// display playing emitter count when the sound system is overwhelmed
|
||||
int total = 0, veryLow = 0, low = 0, def = 0, high = 0, veryHigh = 0;
|
||||
|
||||
// find emitters that are done playing and add them to the nextFreeEmitters list
|
||||
for ( int i = 0; i < playingEmitters.size; ) {
|
||||
if ( playingEmitters[i] == null ) {
|
||||
Debug.LogError( "[AudioManager] ERROR: playingEmitters list had a null emitter! Something nuked a sound emitter!!!" );
|
||||
playingEmitters.RemoveAtFast( i );
|
||||
return;
|
||||
}
|
||||
if ( !playingEmitters[i].IsPlaying() ) {
|
||||
// add to the free list and remove from the playing list
|
||||
if ( verboseLogging ) {
|
||||
if ( nextFreeEmitters.Contains( playingEmitters[i] ) ) {
|
||||
Debug.LogError( "[AudioManager] ERROR: playing sound emitter already in the free emitters list!" );
|
||||
}
|
||||
}
|
||||
playingEmitters[i].Stop();
|
||||
nextFreeEmitters.Add( playingEmitters[i] );
|
||||
playingEmitters.RemoveAtFast( i );
|
||||
continue;
|
||||
}
|
||||
// debugging/profiling
|
||||
if ( verboseLogging && showPlayingEmitterCount ) {
|
||||
total++;
|
||||
switch ( playingEmitters[i].priority ) {
|
||||
case SoundPriority.VeryLow: veryLow++; break;
|
||||
case SoundPriority.Low: low++; break;
|
||||
case SoundPriority.Default: def++; break;
|
||||
case SoundPriority.High: high++; break;
|
||||
case SoundPriority.VeryHigh: veryHigh++; break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if ( verboseLogging && showPlayingEmitterCount ) {
|
||||
Debug.LogWarning( string.Format( "[AudioManager] Playing sounds: Total {0} | VeryLow {1} | Low {2} | Default {3} | High {4} | VeryHigh {5} | Free {6}", Fmt( total ), Fmt( veryLow ), Fmt( low ), Fmt( def ), Fmt( high ), Fmt( veryHigh ), FmtFree( nextFreeEmitters.Count ) ) );
|
||||
showPlayingEmitterCount = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
Fmt()
|
||||
-----------------------
|
||||
*/
|
||||
string Fmt( int count ) {
|
||||
float t = count / (float)theAudioManager.maxSoundEmitters;
|
||||
if ( t < 0.5f ) {
|
||||
return "<color=green>" + count.ToString() + "</color>";
|
||||
} else if ( t < 0.7 ) {
|
||||
return "<color=yellow>" + count.ToString() + "</color>";
|
||||
} else {
|
||||
return "<color=red>" + count.ToString() + "</color>";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
FmtFree()
|
||||
-----------------------
|
||||
*/
|
||||
string FmtFree( int count ) {
|
||||
float t = count / (float)theAudioManager.maxSoundEmitters;
|
||||
if ( t < 0.2f ) {
|
||||
return "<color=red>" + count.ToString() + "</color>";
|
||||
} else if ( t < 0.3 ) {
|
||||
return "<color=yellow>" + count.ToString() + "</color>";
|
||||
} else {
|
||||
return "<color=green>" + count.ToString() + "</color>";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
OnPreSceneLoad()
|
||||
-----------------------
|
||||
*/
|
||||
void OnPreSceneLoad() {
|
||||
// move any attached sounds back to the sound emitters parent before changing levels so they don't get destroyed
|
||||
Debug.Log( "[AudioManager] OnPreSceneLoad cleanup" );
|
||||
for ( int i = 0; i < soundEmitters.Length; i++ ) {
|
||||
soundEmitters[i].Stop();
|
||||
soundEmitters[i].ResetParent( soundEmitterParent.transform );
|
||||
}
|
||||
// reset our emitter lists
|
||||
ResetFreeEmitters();
|
||||
}
|
||||
|
||||
/*
|
||||
-----------------------
|
||||
ResetFreeEmitters()
|
||||
-----------------------
|
||||
*/
|
||||
< |