Scene Transition Script

This commit is contained in:
mushgunAX 2023-02-27 15:28:05 +08:00
parent b4930b63f5
commit f9c90ece7e
2 changed files with 66 additions and 0 deletions

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