annulusgames / lucidaudio Goto Github PK
View Code? Open in Web Editor NEWSimple audio player for unity
License: MIT License
Simple audio player for unity
License: MIT License
LucidAudio.PlayBGMで再生しているAudioPlayerに関して、LucidAudio.BGMVolumeが1以外の状態でFadeVolume関数を使うと開始時の音量が関数を呼ぶ前から変化する(元の値 * LucidAudio.BGMVolumeになる)
UpdateFadeVolume関数では開始時の音量と終了時の音量をLerpで補完してSetVolumeに入れていますが、開始時の音量(fadeVolumeStartValue)はaudioSource.volumeをそのまま設定しているためSetVolumeを通すとLucidAudio.BGMVolumeが乗算される処理のために最初の音量と違う値から開始してしまうのだと考えました。
自分なりに下記のようにfadeVolumeStartValueを修正したので、参考にしていただけたらと思います。
public void FadeVolume(float endValue, float duration, Action callback = null)
{
if (duration > 0)
{
fadeVolumeStartTime = Time.realtimeSinceStartup;
fadeVolumeDuration = duration;
switch (audioType)
{
default:
fadeVolumeStartValue = audioSource.volume;
break;
case AudioType.BGM:
fadeVolumeStartValue = LucidAudio.BGMVolume == 0 ? 1 : (audioSource.volume / LucidAudio.BGMVolume);
break;
case AudioType.SE:
fadeVolumeStartValue = LucidAudio.SEVolume == 0 ? 1 : (audioSource.volume / LucidAudio.SEVolume);
break;
}
fadeVolumeEndValue = endValue;
onFadeVolumeComplete = callback;
isFadeVolumePlaying = true;
}
else
{
audioSource.volume = endValue;
callback?.Invoke();
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.