public void Play(string audioFile) { if (String.IsNullOrEmpty(audioFile)) { return; } if (TriggerOnce && hasTriggered) { return; } if (String.IsNullOrEmpty(Event)) { return; } if (!eventDescription.isValid()) { Lookup(); } bool isOneshot = false; if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase)) { eventDescription.isSnapshot(out isOneshot); } bool is3D = false; eventDescription.is3D(out is3D); if (!instance.isValid()) { instance.clearHandle(); } if (isOneshot && instance.isValid()) { instance.release(); instance.clearHandle(); } if (!instance.isValid()) { eventDescription.createInstance(out instance); if (is3D) { var rigidBody = GetComponent <Rigidbody>(); var rigidBody2D = GetComponent <Rigidbody2D>(); var transform = GetComponent <Transform>(); if (rigidBody) { instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody); } else { instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D); } } } foreach (var param in Params) { instance.setParameterValue(param.Name, param.Value); } if (is3D && OverrideAttenuation) { instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance); instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance); } ExtensionsManager.PlayProgrammerSound(audioFile, this.instance); hasTriggered = true; }
public void Init_Attachment(Transform position, Rigidbody rb) { RuntimeManager.AttachInstanceToGameObject(event_Instance, position, rb); }
/// <summary> /// Attach the fmodEvent to a transfom /// </summary> /// <param name="_target">target transfomr</param> public void FollowTarget(Transform _target) { RuntimeManager.AttachInstanceToGameObject(m_fmodEventInstance, _target, _target.GetComponent <Rigidbody>()); }
// Update is called once per frame void Update() { RuntimeManager.AttachInstanceToGameObject(bellsoundEvent, affordance.transform, affordance.GetComponent <Rigidbody>()); RuntimeManager.AttachInstanceToGameObject(trainSoundevent, train.transform, train.GetComponent <Rigidbody>()); }
public void BindEvent(int eventID, Transform targetTransform, Rigidbody2D targetBody = null) { RuntimeManager.AttachInstanceToGameObject(m_SpawnedInstances[eventID], targetTransform, targetBody); m_SpawnedInstances[eventID].set3DAttributes(RuntimeUtils.To3DAttributes(targetTransform)); }
private void PlayWhipSound() { RuntimeManager.AttachInstanceToGameObject(whipSound, midConnectedBody.transform, midConnectedBody); //whipSound.set3DAttributes(RuntimeUtils.To3DAttributes(midConnectedBody.transform)); whipSound.start(); }
private void Awake() { exitAmbiance = RuntimeManager.CreateInstance(exitAmbianceEvent); RuntimeManager.AttachInstanceToGameObject(exitAmbiance, GetComponent <Transform>(), GetComponent <Rigidbody>()); exitAmbiance.start(); }
/// <summary> /// Attach an event to current transform /// </summary> /// <param name="_eventInstance">fmod event instance</param> /// <param name="_emitterTransform">transform to attach event</param> public void AttachSfx(EventInstance _eventInstance, Transform _emitterTransform) { RuntimeManager.AttachInstanceToGameObject(_eventInstance, _emitterTransform, GetComponent <Rigidbody2D>()); _eventInstance.set3DAttributes(RuntimeUtils.To3DAttributes(_emitterTransform.position)); }