Unity RaycastHit.transform.tag working in editor not working on Android


So here is my script

 if (Input.GetMouseButtonDown(0))
            RaycastHit hit;
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
                if (hit.transform.tag == "Ground")

The function works perfectly within the editor but doesn’t work on android build. Without the if statement checking for the tag, the function works on android as well.

It only doesn’t work when I have set a custom tag to the gameobject. And it only stop working if I try to access the tag name via script.

It’s working. It seems that when you remove a tag from the tag manager and then build the apk without restarting unity, this problem happens. I guess its a bug. Simply closing Unity and reopening got it working. Then i tried removing a tag and built an apk and it gave me the same problem. I once again closed the project and reopened it and everything was working fine.