Why isn't ScreenPointToRay() working in WebGL after building?

In the editor it works, but after building to WebGL, from Unity 2020.2.0f1, it doesn’t.

What magical hidden obscure Wizard-tier build option did I miss?

Actually this doesn’t work in any build I have tried including Windows Standalone and UWP.

What is going on? Why am I using something no one else is? Why is this is a feature if it is broken? How can I work around this?

[edit] This is extremely frustrating as I simply assumed this would work and am currently losing everything I had built up for a customer case.

Ok, I fixed it, and I have no idea why this works:

I changed a tag name into another name.

Then magically it works!

There is only one reference to this tag in the code and it’s only used if it cannot otherwise find the object using GetComponentOfType<> even after it has been explicitly assigned through the inspector field!

I wish I knew what was going on.

I know that builds have a problem if there are gaps in the inspector (tags).
That happens if you delete a tag (not the last one in the list). If you restart the editor it’s fixed.

1 Like

It sounds like you did have to go through some frustrating debugging. Sorry I’m not able to help on this one. If you figure out a deterministic way of how to get the tag into a bad state, may be worth raising a bug against the Editor, and see what their team thinks about it. Even if it is “just” a user error, or an UI footgun gotcha, then maybe the UX can still be improved to avoid such trouble in the future.

1 Like

That’s it, I hope. I really hope. This was so weird.

I think maybe it was caused by the fact that I imported parts of an existing UWP-project, then switched the platform to WebGL, and then did a few things to tweak the settings towards making it compatible with WebGL…

Anyhow, problem resolved.