我们创建了 Fontainebleau 演示来说明摄影photogrammetry流程和 LayeredLit 着色器的使用。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

57 行
1.8 KiB

using System.Collections;
using System;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
namespace GameplayIngredients.Actions
{
public class AudioMixParameterAction : ActionBase
{
public AudioMixer AudioMixer;
public string Parameter;
public float Value;
public float InterpDuration = 0;
public UnityEvent OnInterpComplete;
Coroutine m_Coroutine;
public override void Execute(GameObject instigator = null)
{
if (InterpDuration <= 0.0f)
{
AudioMixer.SetFloat(Parameter, Value);
}
else
{
if (m_Coroutine != null)
StopCoroutine(m_Coroutine);
m_Coroutine = StartCoroutine(InterpParameterCoroutine(AudioMixer, InterpDuration, Parameter, Value, OnInterpComplete));
}
}
IEnumerator InterpParameterCoroutine(AudioMixer mixer, float duration, string parameter, float targetvalue, UnityEvent onInterpComplete)
{
float initial = 0.0f;
if (mixer.GetFloat(parameter, out initial))
{
float t = 0.0f;
t += Time.deltaTime / duration;
while (t < 1.0f)
{
mixer.SetFloat(parameter, Mathf.Lerp(initial, targetvalue, t));
yield return new WaitForEndOfFrame();
}
mixer.SetFloat(parameter, targetvalue);
yield return new WaitForEndOfFrame();
onInterpComplete.Invoke();
}
else
{
throw new InvalidOperationException("Parameter " + parameter + " does not exist on target AudioMixer : " + mixer.name);
}
}
}
}