diff --git a/Assets/Scripts/UI/SC_SceneFadeInOut.cs b/Assets/Scripts/UI/SC_SceneFadeInOut.cs new file mode 100644 index 00000000..34cfdc78 --- /dev/null +++ b/Assets/Scripts/UI/SC_SceneFadeInOut.cs @@ -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(); + alphaValue = fadeR.Material.GetProperty("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("data.alpha", alphaValue); + } + } + } +} diff --git a/Assets/Scripts/UI/SC_SceneFadeInOut.cs.shmeta b/Assets/Scripts/UI/SC_SceneFadeInOut.cs.shmeta new file mode 100644 index 00000000..ddebe65c --- /dev/null +++ b/Assets/Scripts/UI/SC_SceneFadeInOut.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_SceneFadeInOut +ID: 153328192 +Type: 9