Script runs fine in Editor but misbehaves in Standalone or other builds

I am curious as what might cause a script to run fine in the editor but not in standalone build?

 IEnumerator MakeMaterialInvisible(Material mat)
    {  
        float fadeAmount = mat.GetFloat("_FadeAmount");
          
        while (fadeAmount < 1.0f  roomVisibilityState == VisibilityState.MakeInvisible)
        {
            fadeAmount += Time.deltaTime * 1 / 0.5f;            
	        mat.SetFloat("_FadeAmount", Mathf.Min(1.0f, fadeAmount);                              
            yield return null;
        }
    }

In the editor, the material does “fade” away but in the standalone build, it is unaffected by these _FadeAmount changes. It seems like the material being manipulated could be an instance instead of what is applied to the objects but why would this behave differently in the editor vs. a standalone build? Am I missing something trivial here?

[Update] Seems like whatever material tweaks (texture assignments, etc) that might have been made in the editor, do not exist in the build version. Since I was making a copy of the original material. Changing its shader, I failed to assign a special texture needed to fade the object. In the editor, whatever tweaks I might have made to these objects using this shader was being remembered but that is not the case in the standalone version…

Are you sure that the shader used on the material is in resources unless the material is used on a object present in a scene thats included or used on a prefab in resources?

Otherwise the shader will not be present in the build which could lead to this kind of problems if it falls back to something else for example (or when you are lucky to pink → no shader present)

Prior to moving the Shader to resources, I was getting the wonderful Pink Shader (which like you said is a nice visual indicator of no shader present).

The issue occurs as a result of copying one Material to another and switching to a new Shader that requires an extra map. I am pretty sure I had this working before but for whatever reason, the Material tweaks using this new Shader which had been assigned to each material for (tweaking) do not carry through the build versions.

It does make sense that it would not work as how would Unity know what texture or settings to use with this newly created / duplicated material to which I assign a new Shader.