Last active
September 3, 2016 12:58
-
-
Save Arakade/6098f434054b0b5ab7cfbe7d744d4df2 to your computer and use it in GitHub Desktop.
Patch for RealisticWater Unity Asset's RippleCreator to integrate with MasterAudio for splash sound. https://www.assetstore.unity3d.com/en/#!/content/33434
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Assets/RealisticWater/Scripts/Water/RippleCreator.cs b/Assets/RealisticWater/Scripts/Water/RippleCreator.cs | |
index 9282d1b..cee8c48 100644 | |
--- a/Assets/RealisticWater/Scripts/Water/RippleCreator.cs | |
+++ b/Assets/RealisticWater/Scripts/Water/RippleCreator.cs | |
@@ -1,3 +1,6 @@ | |
+// define to include Master Audio integration for splash sound | |
+#define MASTERAUDIO | |
+ | |
using UnityEngine; | |
using System.Collections.Generic; | |
@@ -10,7 +13,13 @@ public class RippleCreator : MonoBehaviour | |
public float reversedRippleDelay = 0.2f; | |
public GameObject SplashEffect; | |
public GameObject SplashEffectMoved; | |
+ | |
+#if MASTERAUDIO | |
+ [SerializeField] | |
+ private string soundName; | |
+#else | |
public AudioSource SplashAudioSource; | |
+#endif | |
private int fadeInVelocityLimit = 10; | |
private int fadeInVelocity = 1; | |
@@ -84,8 +93,14 @@ public class RippleCreator : MonoBehaviour | |
reversedVelocityQueue.Clear(); | |
triggeredTime = Time.time; | |
fadeInVelocity = 1; | |
- | |
+ | |
+#if MASTERAUDIO | |
+ if (!string.IsNullOrEmpty(soundName)) | |
+ DarkTonic.MasterAudio.MasterAudio.PlaySound3DAtTransformAndForget(soundName, transform); | |
+#else | |
if(SplashAudioSource!=null) SplashAudioSource.Play(); | |
+#endif | |
+ | |
if (SplashEffect!=null) { | |
var offset = waterRipples.GetOffsetByPosition(t.position); | |
offset.x = t.position.x; | |
@@ -156,4 +171,4 @@ public class RippleCreator : MonoBehaviour | |
public Vector3 Position; | |
public float Velocity; | |
} | |
-} | |
\ No newline at end of file | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment