Hello! In a game I am working on, items flash when they are ready to upgrade, however I’ve ran into an issue with the flashing. I am using a shader to achieve the flashing effect that has a float on it that changes the intensity of the flash, well it works great until the player reloads the game, then something that was flashing before no longer flashes at all forever (The game saves).
Here is the code I use to make the shader flash:
if(flashing)
{
if (upgradeShineAmount >= 14)
{
addShineAmount = false;
}
else if (upgradeShineAmount <= 1)
{
addShineAmount = true;
}
upgradeShineAmount += addShineAmount ? Time.deltaTime * 5 : (Time.deltaTime * 5) * -1;
GetComponent<Renderer>().material.SetFloat(Shader.PropertyToID("_RimPower"), upgradeShineAmount);
DynamicGI.UpdateMaterials(GetComponent<Renderer>());
}
else if(isActive)
{
upgradeShineAmount = 15;
GetComponent<Renderer>().material.SetFloat(Shader.PropertyToID("_RimPower"), upgradeShineAmount);
DynamicGI.UpdateMaterials(GetComponent<Renderer>());
}
If I change the GetCompenent().material to a reference to the actual objects material it all works, except it will change it on other gameobjects using the same material, which I cannot do. I’ve googled a ton and cannot find a solution. Thanks for any help!