2025-01-07 17:33:31 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
#if FMOD_AVAILABLE
|
|
|
|
using FMOD;
|
|
|
|
using FMODUnity;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
public class OnStirringSound : MonoBehaviour
|
|
|
|
{
|
2025-01-08 14:14:10 +01:00
|
|
|
#if FMOD_AVAILABLE
|
2025-01-07 17:33:31 +01:00
|
|
|
[SerializeField]
|
2025-01-08 21:05:21 +01:00
|
|
|
Rigidbody _rigidbody;
|
2025-01-07 17:33:31 +01:00
|
|
|
|
2025-01-08 21:05:21 +01:00
|
|
|
StudioEventEmitter _stirringSoundEvent;
|
2025-01-07 17:33:31 +01:00
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
2025-01-08 21:05:21 +01:00
|
|
|
_stirringSoundEvent = GetComponent<StudioEventEmitter>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (_rigidbody.velocity != Vector3.zero)
|
|
|
|
{
|
|
|
|
if (!_stirringSoundEvent.IsPlaying())
|
|
|
|
{
|
|
|
|
_stirringSoundEvent.Play();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_stirringSoundEvent.Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
{
|
|
|
|
_stirringSoundEvent.Stop();
|
2025-01-07 17:33:31 +01:00
|
|
|
}
|
2025-01-08 14:14:10 +01:00
|
|
|
#endif
|
2025-01-07 17:33:31 +01:00
|
|
|
}
|