Comments (6)
Could you describe your feature request in more detail? It is currently unclear what exactly is requested.
Perhaps the example scene can provide some help. AdvancedExamples.cs
from unity-audio-manager.
TransitionTo
Fade in and fade out transitions
from unity-audio-manager.
for example Play("Main_Menu");
then I call Play("Lobby");
and MainMenu smoothly reduces the volume
and the Lobby will gradually increase the volume from 0
from unity-audio-manager.
This is how you would add a fade in effect on the volume, as can be seen in the AdvancedExamples.cs to any song.
am.SubscribeProgressCoroutine(fadeInSong.soundName, 0f, SongProgressCallback);
am.Play(fadeInSong.soundName);
public ProgressResponse InitFadeInSong(string name, float progress, ChildType child) {
am.TryGetSource(name, out var source);
source.Volume = 0f;
am.LerpVolume(name, fadeInEndVolume, clipFadeInTime);
return ProgressResponse.RESUB_IN_LOOP;
}
And this is how you would a fade out effect on the volume to any song.
am.TryGetSource(fadeOutSong.soundName, out var source);
float progress = ((source.Source.clip.length - clipFadeOutTime) / source.Source.clip.length);
am.SubscribeProgressCoroutine(fadeOutSong.soundName, progress, HandleFadeOutSong);
am.Play(fadeOutSong.soundName);
private ProgressResponse HandleFadeOutSong(string name, float progress, ChildType child) {
am.LerpVolume(name, 0f, progress);
return ProgressResponse.UNSUB;
}
For your case the fadeInSong.soundName
, would be "Lobby" and fadeOutSong.soundName
would be "Main_Menu".
from unity-audio-manager.
Can you provide a more detailed example, something I can’t figure out how to do?
I want to write a function
Transition (string fadeInSong, string fadeOutSong)
from unity-audio-manager.
When exactly would you call this method in your code? Simply once at the startup.
Or do you call it by yourself, once you want to transition from the main_menu to the lobby song?
For now this would be an Example method to fade out an already playing "Main_Menu" theme in 1 second and in that one second also starting fading in the "Lobby" theme.
private void TransitionWithFading(string fadeInSong, string fadeOutSong, float clipFadeInTime = 1f) {
// Slowly decrease volume of the already playing song and slowly start to decrease the volume
am.LerpVolume(fadeOutSong, 0f, clipFadeInTime);
// Set volume to 0 before playing the song and slowly start to increase the volume
am.TryGetSource(fadeInSong, out var source);
float originalVolume = source.Volume;
source.Volume = 0f;
am.Play(fadeInSong);
am.LerpVolume(fadeInSong, originalVolume, clipFadeInTime);
}
from unity-audio-manager.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity-audio-manager.