Adding server room sound effects and button to trigger them

This commit is contained in:
Ranno Samuel Adson 2025-01-02 16:37:16 +02:00
parent de968605ec
commit 98094a9f5f
22 changed files with 574 additions and 6 deletions

View File

@ -55,6 +55,10 @@ namespace UnityEngine.XR.Content.Interaction
[SerializeField]
[Tooltip("Events to trigger when the button pressed value is updated. Only called when the button is pressed")]
ValueChangeEvent m_OnValueChange;
[SerializeField]
[Tooltip("Audio source to play when the button is pressed")]
AudioSource m_AudioSource;
bool m_Pressed = false;
bool m_Toggled = false;
@ -247,6 +251,11 @@ namespace UnityEngine.XR.Content.Interaction
{
if (m_Pressed)
m_OnRelease.Invoke();
// Play sound if the audio source is set
if (m_AudioSource != null)
{
m_AudioSource.Play();
}
}
}
m_Pressed = pressed;

View File

@ -67,10 +67,10 @@ public class StencilPortal : MonoBehaviour
private void OnTriggerExit(Collider other)
{
if (!_shouldTeleport || IsInvoking(nameof(AllowTeleport))) return;
/*if (!_shouldTeleport || IsInvoking(nameof(AllowTeleport))) return;
if (!other.CompareTag("Player")) return;
Debug.Log(transform.name + " player exited");
Invoke(nameof(AllowTeleport), 1f);
Invoke(nameof(AllowTeleport), 1f);*/
}
private void AllowTeleport()

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0eddafeb95d1c064a9b3cac556cb6273
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using UnityEngine;
using UnityEngine.PlayerLoop;
using UnityEngine.XR.Content.Interaction;
public class AlarmTrigger : MonoBehaviour
{
public XRPushButton PushButton;
public AudioSource AlarmSequence;
public AudioSource VentilationSequence;
private bool hasAlarm = false;
void Start()
{
if (PushButton != null)
{
PushButton.onPress.AddListener(OnButtonPressed);
}
}
void OnButtonPressed()
{
Debug.Log("Alarm button Pressed!");
VentilationSequence.Stop();
AlarmSequence.Play();
hasAlarm = true;
}
void Update()
{
if(hasAlarm && !AlarmSequence.isPlaying) // If alarm state has ended.
{
VentilationSequence.Play(); // Return to normal.
hasAlarm = false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b1376204c7c3df4b826e208e82f8d99
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &2378157237066378142
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalScale.x
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalScale.y
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalScale.z
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalPosition.x
value: -32.66
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalPosition.y
value: 5.659
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalPosition.z
value: -13.749
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: -90
objectReference: {fileID: 0}
- target: {fileID: 3130556819844574636, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_ConstrainProportionsScale
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3399821747579187769, guid: da3b468b35b58334693dfcd04f6e06a7,
type: 3}
propertyPath: m_Name
value: PushButton Variant
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: da3b468b35b58334693dfcd04f6e06a7, type: 3}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 63baceba050c1ab428ea7d709d0756b4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,254 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &7905546272495494873
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalScale.x
value: 70
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalScale.y
value: 70
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalScale.z
value: 70
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalPosition.x
value: 5.1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_ConstrainProportionsScale
value: 1
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
propertyPath: m_Name
value: Server rack
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
insertIndex: -1
addedObject: {fileID: 3964068808109647281}
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
insertIndex: -1
addedObject: {fileID: 2488785156293713400}
m_SourcePrefab: {fileID: 100100000, guid: ac65e655dd40bcd48b72b3f8ddcf45bd, type: 3}
--- !u!1 &7023167506039495560 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: ac65e655dd40bcd48b72b3f8ddcf45bd,
type: 3}
m_PrefabInstance: {fileID: 7905546272495494873}
m_PrefabAsset: {fileID: 0}
--- !u!64 &3964068808109647281
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7023167506039495560}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 6074735673208717538, guid: ac65e655dd40bcd48b72b3f8ddcf45bd, type: 3}
--- !u!82 &2488785156293713400
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7023167506039495560}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 5bcb02b6a0d913d4c90781538c787b2f, type: 3}
m_PlayOnAwake: 1
m_Volume: 0.05
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 10
Pan2D: 0
rolloffMode: 2
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0.1
value: 1
inSlope: -10.0039835
outSlope: -10.0039835
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.2
value: 0.5
inSlope: -2.5009959
outSlope: -2.5009959
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.4
value: 0.25
inSlope: -0.62524897
outSlope: -0.62524897
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.7940491
value: 0.057891846
inSlope: -0.27374932
outSlope: -0.27374932
tangentMode: 0
weightedMode: 0
inWeight: 0.24773687
outWeight: 0
- serializedVersion: 3
time: 1
value: 0.018304445
inSlope: -0.10003988
outSlope: -0.10003988
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
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
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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c5621e62bf6f9ac4c9f0283716faa591
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d02f8c90588f00438fb598bed8b011f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3c6366024c77e2155f84dd8d9986ba834f756c6128a3fd617dcf75b4b4151c68
size 5144722

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 5bcb02b6a0d913d4c90781538c787b2f
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5cea42a9134cf264853b6d565faa71e95fd5e5b592c1c73b9ebef8b945486ab9
size 17371802

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: ac0bdbeb07c7f634c82380d550d745c4
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:16e618e89a9822d9167a70edcf30ba810797d2ccbd1ede3c634c365c58408ed4
size 11616

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: bb4289b50124ef84bbeff826da78b01d
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f8aa3954c97ef0c84a6b988d77aaceaaa9b561025a210143dc10e0c42a458a9a
size 222972

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: cfb28986f1c05f641869c308ca1effc2
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4df5db895d6db935d511e0d91700caedd231d087cb2810af539344becb320ffd
size 761976

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: f10e6b03b52211c40a4de4eb907645d8
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:82a4717216b41cdb6593053eddd1fe14aa9dfa83a2adeae511dc830ec60ea73a
size 370252
oid sha256:c3b2836c119fff40ee96f461fda0d39d8f81b614e6d9d384cd562cebd5249c20
size 340956

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5c5fdb2b888d76fb308f11a7e1cc1f7e4ea6e65c39235bd6a50ce523141da3fe
size 127321811
oid sha256:7f9dc024f4b1620b3db9a8aed57ede9c0e9ace6b6c966411e0a915a94a889c2d
size 127292437