Hi,
I’m trying to fade a texture which uses this shader but can’t seem to get the alpha to change on screen. It seems to read the initial alpha value as 0 (when it should be 0.5).
Can anyone tell me where I might be going wrong?
The script I am using is below:
Thanks
{
// The current colour value of the renderer
exhaustTempColor = PlayerExhaust_Thrust_1.material.color;
Debug.Log("exhaustTempColor.color = " + exhaustTempColor);
if (fadeFlag == true)
{
while (exhaustAlphaValue > ExhaustLowTargetAlpha)
{
Debug.Log("FADING OUT EXHAUSTS");
Debug.Log("Exhaust Alpha = " + PlayerExhaust_Thrust_1.material.color.a);
yield return new WaitForEndOfFrame();
// The current alpha value of the renderer
exhaustTempColor.a = exhaustAlphaValue;
// Exhaust 1
PlayerExhaust_Thrust_1.material.color = exhaustTempColor;
// Decrease the alpha value of the renderer
exhaustAlphaValue -= Time.deltaTime * fadingSpeed;
}
}
if (fadeFlag == false)
{
Debug.Log("FADING IN EXHAUSTS");
Debug.Log("Exhaust Alpha = " + PlayerExhaust_Thrust_1.material.color.a);
yield return new WaitForEndOfFrame();
// The current alpha value of the renderer
exhaustTempColor.a = exhaustAlphaValue;
PlayerExhaust_Thrust_1.material.color = exhaustTempColor;
// Decrease the alpha value of the renderer
exhaustAlphaValue = 0.5f;
}
// The current alpha value of the renderer
exhaustTempColor.a = exhaustAlphaValue;
// Exhaust 1
PlayerExhaust_Thrust_1.material.color = exhaustTempColor;
}