From 59875d1523f433b30bbd6f96a490df33e762d366 Mon Sep 17 00:00:00 2001 From: Maximilian Wagner Date: Thu, 22 Jun 2023 21:02:46 +0200 Subject: [PATCH] Musik-Changer Skript erstellt und in Level11 eingebaut --- .../AssetsFORELLE/Script/TempMusicChange.cs | 69 ++++++++++ .../Script/TempMusicChange.cs.meta | 11 ++ Assets/Scenes/ScenesInGame/11Catman2.unity | 128 +++++++++++++++++- 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 Assets/AssetsFORELLE/Script/TempMusicChange.cs create mode 100644 Assets/AssetsFORELLE/Script/TempMusicChange.cs.meta diff --git a/Assets/AssetsFORELLE/Script/TempMusicChange.cs b/Assets/AssetsFORELLE/Script/TempMusicChange.cs new file mode 100644 index 0000000..8894136 --- /dev/null +++ b/Assets/AssetsFORELLE/Script/TempMusicChange.cs @@ -0,0 +1,69 @@ +using System; +using Unity.VisualScripting; +using UnityEngine; + +public class TempMusicChange : MonoBehaviour +{ + public AudioClip changeClipTo; + + private AudioSource audioSource; + private AudioClip originalClip; + + private AudioReverbFilter rev; + private AudioLowPassFilter lpf; + + + // Start is called before the first frame update + void Start() + { + GameObject audioController = GameObject.Find("AudioController"); + audioSource = audioController.GetComponent(); + rev = audioController.GetComponent(); + lpf = audioController.GetComponent(); + originalClip = audioSource.clip; + } + + // Update is called once per frame + void Update() + { + + } + + private void OnTriggerEnter2D(Collider2D other) + { + if (!other.tag.Equals("Player")) + return; + + + audioSource.clip = changeClipTo; + audioSource.Play(); + + checkFilters(true); + } + + private void OnTriggerExit2D(Collider2D other) + { + if (!other.tag.Equals("Player")) + return; + + + audioSource.clip = originalClip; + audioSource.Play(); + + checkFilters(false); + } + + void checkFilters(bool enter) + { + if (enter) + { + rev.enabled = false; + lpf.enabled = false; + } + else + { + rev.enabled = true; + lpf.enabled = true; + } + } +} diff --git a/Assets/AssetsFORELLE/Script/TempMusicChange.cs.meta b/Assets/AssetsFORELLE/Script/TempMusicChange.cs.meta new file mode 100644 index 0000000..a65e335 --- /dev/null +++ b/Assets/AssetsFORELLE/Script/TempMusicChange.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 379b43d0e0b0cf343af62688327550c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/ScenesInGame/11Catman2.unity b/Assets/Scenes/ScenesInGame/11Catman2.unity index 1a33a77..1e64c97 100644 --- a/Assets/Scenes/ScenesInGame/11Catman2.unity +++ b/Assets/Scenes/ScenesInGame/11Catman2.unity @@ -189417,6 +189417,7 @@ Transform: - {fileID: 1399078248} - {fileID: 138335581} - {fileID: 1867752658} + - {fileID: 1470494306} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -260944,6 +260945,131 @@ Grid: m_CellGap: {x: 0, y: 0, z: 0} m_CellLayout: 0 m_CellSwizzle: 0 +--- !u!1 &1470494305 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1470494306} + - component: {fileID: 1470494309} + - component: {fileID: 1470494308} + - component: {fileID: 1470494307} + m_Layer: 0 + m_Name: MusicSwitcher + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1470494306 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1470494305} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 7.5205, y: 4.4798, z: 0} + m_LocalScale: {x: 11.288899, y: 5.5155425, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1138134438} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1470494307 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1470494305} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 379b43d0e0b0cf343af62688327550c8, type: 3} + m_Name: + m_EditorClassIdentifier: + changeClipTo: {fileID: 8300000, guid: f1978f6756b7c4a6780a67ab04cf9ef3, type: 3} +--- !u!61 &1470494308 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1470494305} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!212 &1470494309 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1470494305} + m_Enabled: 0 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &1472463648 GameObject: m_ObjectHideFlags: 0 @@ -262394,7 +262520,7 @@ AudioListener: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2096156527} - m_Enabled: 1 + m_Enabled: 0 --- !u!20 &2096156531 Camera: m_ObjectHideFlags: 0