[英]FMOD parameter not changing through C# script
I'm currently trying to develop my first mini game (a VR musical experience).我目前正在尝试开发我的第一个迷你游戏(VR 音乐体验)。
I'm trying to have the value of a slider control an FMOD parameter, but nothing happens.我试图让滑块控制 FMOD 参数的值,但没有任何反应。 Plus the function does not show in the On Value Changed of the slider...
另外,该功能未显示在滑块的 On Value Changed 中...
I'm already using that slider to control the transparency of a material and if I try changing the FMOD parameter manually in the inspector it works just fine.我已经在使用该滑块来控制材质的透明度,如果我尝试在检查器中手动更改 FMOD 参数,它就可以正常工作。
Here is the script:这是脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FMODParameters : MonoBehaviour
{
FMODUnity.StudioEventEmitter changeVolume;
FMOD.Studio.EventInstance bass;
public string bassVolumeParameter;
public Slider slider;
void Start()
{
changeVolume = GetComponent<FMODUnity.StudioEventEmitter>();
bass = FMODUnity.RuntimeManager.CreateInstance("event:/Beat/2D/2D Bass");
slider = GetComponent<Slider>();
}
// Update is called once per frame
void Update()
{
SetBassVolume();
}
void SetBassVolume()
{
bass.setParameterByName(bassVolumeParameter, slider.value / 250);
}
}
Thanks in advance for the help!在此先感谢您的帮助! :)
:)
The problem is that you have to add the function in the onValueChanged () listener.问题是您必须在 onValueChanged () 侦听器中添加该函数。 To do it:
去做吧:
But first you should tweak the method a bit, like so:但首先你应该稍微调整一下方法,如下所示:
void SetBassVolume(float _value)
{
bass.setParameterByName(bassVolumeParameter, _value / 250);
}
Good work!干得好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.