Implemented Fade In To and Fade Out From Black Scene Transitions #378

Merged
mushgunAX merged 10 commits from scenetransitions into main 2023-03-01 17:55:28 +08:00
2 changed files with 66 additions and 0 deletions
Showing only changes of commit f9c90ece7e - Show all commits

View File

@ -0,0 +1,63 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class SceneFadeInOut : Script
{
[SerializeField]
private GameObject fadeUI;
[Tooltip("If true, the panel fadeUI fades in (increasing alpha). If false, no fading")]
public bool fadeIn;
[Tooltip("If true, the panel fadeUI fades out (decreasing alpha). If false, no fading")]
public bool fadeOut;
[Tooltip("The alpha value of the UI that is faded")]
public float alphaValue;
[SerializeField]
private float fadeInRate;
[SerializeField]
private float fadeOutRate;
private Renderable fadeR;
protected override void awake()
{
fadeR = fadeUI.GetComponent<Renderable>();
alphaValue = fadeR.Material.GetProperty<float>("data.alpha");
}
protected override void start()
{
}
protected override void update()
{
if (fadeR != null)
{
if (fadeIn) //fading in
{
alphaValue += fadeInRate * Time.DeltaTimeF;
if (alphaValue >= 1.0f) alphaValue = 1.0f;
}
if (fadeOut) //fading out
{
alphaValue -= fadeOutRate * Time.DeltaTimeF;
if (alphaValue <= 0.0f) alphaValue = 0.0f;
}
fadeR.Material.SetProperty<float>("data.alpha", alphaValue);
}
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_SceneFadeInOut
ID: 153328192
Type: 9