Material/shader parameter update via script only reflects in editor

I have a prefab that is instantiated on touch input: the player needs to touch and hold for some duration, during which an animation for radial progress around touch position is created by manipulating material/shader attached to the prefab’s sprite renderer.

  • The shader I am referring to is here;
    I attached it to a material, which is referenced by the sprite renderer.

  • The animation seem to work as expected in editor when I test it out in Play/Game mode, but on android it does not show up at all - unless I move the touch position. Below is a part of the prefab script:

      void Start(){
        renderer = GetComponent<SpriteRenderer>();
        mat = renderer.material;      
      }
      
      void Update(){
        if (this.charging){
      
        // Below changes the Shader parameter value '_Arc2'
        // from 360 to 0 within period "duration"
      
          float current_value = mat.GetFloat("_Arc2");        
          if (current_value > 0){
             current_value -= 360f / duration * Time.deltaTime;
             mat.SetFloat("_Arc2", current_value);                                               
          }
        }
      }
    

FWIW. I was able to resolve this issue by simply updating the position of the object back and forth while calling the ‘material update’ function: for some reason this was the only way to ‘refresh’ the material to be actually rendered, since it seems that the parameters were updated already, but the material never rendered.

            // hack: for an unknown reason the updated material - although updated properly - 
            // is never rendered - unless the parent is moved position. 
            // so a movement is done back and forth to refresh it.

            float x = this.transform.position.x;
            float y = this.transform.position.y;            
            this.transform.position = new Vector2(x+1f, y+1f);
 
          //  <animate material properties code here>

            this.transform.position = new Vector2(x, y);