Skip to content

Commit 052f00a

Browse files
committed
feat(Util): Return spawned value for audio and particle system
1 parent 2434681 commit 052f00a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Util.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ public static float GetLayerWeight(Animator ator, int index)
13371337
/// Same with function `AudioSource.PlayClipAtPoint` with different
13381338
/// default `spatialBlend` value.
13391339
/// </summary>
1340-
public static void PlayClipAtPoint(
1340+
public static AudioSource PlayClipAtPoint(
13411341
AudioClip clip,
13421342
Vector3 position,
13431343
float volume,
@@ -1351,6 +1351,7 @@ public static void PlayClipAtPoint(
13511351
audioSource.volume = volume;
13521352
audioSource.Play();
13531353
Object.Destroy(gameObject, clip.length * ((Time.timeScale < 0.01f) ? 0.01f : Time.timeScale));
1354+
return audioSource;
13541355
}
13551356

13561357
#endregion
@@ -1360,17 +1361,18 @@ public static void PlayClipAtPoint(
13601361
/// <summary>
13611362
/// Play the particle at point.
13621363
/// </summary>
1363-
public static void PlayParticleAtPoint(ParticleSystem ps, Vector3 position)
1364+
public static ParticleSystem PlayParticleAtPoint(ParticleSystem ps, Vector3 position)
13641365
{
1365-
PlayParticleAtPoint(ps, position, ps.main.duration);
1366+
return PlayParticleAtPoint(ps, position, ps.main.duration);
13661367
}
1367-
public static void PlayParticleAtPoint(ParticleSystem ps, Vector3 position, float duration)
1368+
public static ParticleSystem PlayParticleAtPoint(ParticleSystem ps, Vector3 position, float duration)
13681369
{
13691370
ParticleSystem particleSystem = MonoBehaviour.Instantiate(ps);
13701371
particleSystem.gameObject.name = "One shot particle";
13711372
particleSystem.transform.position = position;
13721373
particleSystem.Play();
13731374
Object.Destroy(particleSystem.gameObject, duration);
1375+
return particleSystem;
13741376
}
13751377

13761378
#endregion

0 commit comments

Comments
 (0)