forked from cgvr/DeltaVR
FMODi paigaldamine projekti sisse, fmod project created, assets are imported into FMOD; AudioManager and FMODEvents scripts, VR is set up
This commit is contained in:
56
Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs
Normal file
56
Assets/Plugins/FMOD/src/StudioGlobalParameterTrigger.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace FMODUnity
|
||||
{
|
||||
[AddComponentMenu("FMOD Studio/FMOD Studio Global Parameter Trigger")]
|
||||
public class StudioGlobalParameterTrigger: EventHandler
|
||||
{
|
||||
[ParamRef]
|
||||
[FormerlySerializedAs("parameter")]
|
||||
public string Parameter;
|
||||
|
||||
public EmitterGameEvent TriggerEvent;
|
||||
|
||||
[FormerlySerializedAs("value")]
|
||||
public float Value;
|
||||
|
||||
private FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription;
|
||||
public FMOD.Studio.PARAMETER_DESCRIPTION ParameterDescription { get { return parameterDescription; } }
|
||||
|
||||
protected override void HandleGameEvent(EmitterGameEvent gameEvent)
|
||||
{
|
||||
if (TriggerEvent == gameEvent)
|
||||
{
|
||||
TriggerParameters();
|
||||
}
|
||||
}
|
||||
|
||||
public void TriggerParameters()
|
||||
{
|
||||
bool paramNameSpecified = !string.IsNullOrEmpty(Parameter);
|
||||
if (paramNameSpecified)
|
||||
{
|
||||
FMOD.RESULT result = FMOD.RESULT.OK;
|
||||
bool paramIDNeedsLookup = string.IsNullOrEmpty(parameterDescription.name);
|
||||
if (paramIDNeedsLookup)
|
||||
{
|
||||
result = RuntimeManager.StudioSystem.getParameterDescriptionByName(Parameter, out parameterDescription);
|
||||
if (result != FMOD.RESULT.OK)
|
||||
{
|
||||
RuntimeUtils.DebugLogError(string.Format(("[FMOD] StudioGlobalParameterTrigger failed to lookup parameter {0} : result = {1}"), Parameter, result));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result = RuntimeManager.StudioSystem.setParameterByID(parameterDescription.id, Value);
|
||||
if (result != FMOD.RESULT.OK)
|
||||
{
|
||||
RuntimeUtils.DebugLogError(string.Format(("[FMOD] StudioGlobalParameterTrigger failed to set parameter {0} : result = {1}"), Parameter, result));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user