mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
FadeInOut: Added GetDuration
This commit is contained in:
parent
6e2227dcbf
commit
fef184704f
@ -16,6 +16,19 @@ public class FadeInOut : MonoBehaviour
|
||||
[Tooltip("Color to use during scene transition")]
|
||||
public Color fadeColor = Color.black;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates FadeIn / FadeOut time.
|
||||
/// </summary>
|
||||
/// <returns>Duration in seconds</returns>
|
||||
public float GetDuration()
|
||||
{
|
||||
float frames = 1 / (stepRate * 0.1f);
|
||||
float frameRate = Time.deltaTime;
|
||||
float duration = frames * frameRate * 0.1f;
|
||||
Debug.Log($"GetDuration {stepRate} : {frames} * {frameRate} = {duration}");
|
||||
return duration;
|
||||
}
|
||||
|
||||
public IEnumerator FadeIn()
|
||||
{
|
||||
float alpha = fadeImage.color.a;
|
||||
@ -31,6 +44,7 @@ public IEnumerator FadeIn()
|
||||
|
||||
public IEnumerator FadeOut()
|
||||
{
|
||||
Debug.Log("FadeOut");
|
||||
float alpha = fadeImage.color.a;
|
||||
|
||||
while (alpha > 0)
|
||||
|
@ -65,7 +65,7 @@ IEnumerator SendPlayerToNewScene(GameObject player)
|
||||
// Tell client to unload previous subscene. No custom handling for this.
|
||||
conn.Send(new SceneMessage { sceneName = gameObject.scene.path, sceneOperation = SceneOperation.UnloadAdditive, customHandling = true });
|
||||
|
||||
yield return AdditiveLevelsNetworkManager.singleton.fadeInOut.FadeIn();
|
||||
yield return new WaitForSeconds(AdditiveLevelsNetworkManager.singleton.fadeInOut.GetDuration());
|
||||
|
||||
NetworkServer.RemovePlayerForConnection(conn, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user