Quaternions seem broken in Unity 2021 -- act as if gimbal locked!?!

EDIT: Sorry, I seem to have put this in the wrong place by accident – I’d move it if I could, probably belongs in the C# / Code section.

OK, here is some fairly simple code I wrote for a simulation game and tested in Unity 2020 – it seems mathematically correct and 100% worked in Unity 2020, but in Unity 2021 it no longer does. Now, the vertical angle seems to rotate around something dependent on the angle around Y, and not just rotating around the X as it should. Changing between rotation and localRotation does not make a difference (as it shouldn’t since the camera holder has no parent), not does getting the angle from Euler or AngleAxis. Again, it worked perfectly as expect in Unity 2020:

        void AdjustHeading() {
            float rotation = Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime;
            headingAngle += rotation;
            if(headingAngle > 360) headingAngle-= 360;
            else if(headingAngle < 0) headingAngle += 360;
            heading = Quaternion.Euler(0, headingAngle, 0);
        }


        void AdjustPitch() {
            float rotation = Input.GetAxis("Vertical") * rotationSpeed * Time.deltaTime;
            tiltAngle += rotation;
            tiltAngle = Mathf.Clamp(tiltAngle, minPitch, maxPitch);
            tilt = Quaternion.Euler(tiltAngle, 0, 0);
        }


        void SetRotation() {
            angle = heading * tilt;
            transform.rotation = angle;
        }

Is this a bug or an intentional change? And what would I need to do to make it work correctly – rotating separately around the Y and X, as intended and as it did before? Why aren’t quaternions acting like quaternions anymore?!

Step 1 of debugging: print out what the x,y,z,w values of the quaternion are, in both versions of Unity.

I’ve solved the problem – sort-of, I don’t really know what caused it precisely.

I do know now that it has nothing to do with Unity versions – the general cause is even weirder. My camera system worked fine in the demo scene for the “Toon Suburban Pack” by Sics, which was used as an environment to develop and test it, and works again in a simple test scene I just created. When used in “Dreamscape Nature: Mountains” by Polyart Studios the rotation works fine but the classic simulation camera won’t move (a first person camera using the same methods to move does though), and when use with “Toon Fantasy Nature” all movement and rotation about the y axis fine but changing pitch is broken in a way that looks like the axis of rotation is fixed in a way it shouldn’t be.

Why changing which cartoon trees are present could possibly effect this, or what scripts or editor hack might have been include and how they could do this, it completely beyond me – but clearly my code is fine and something else way breaking it.

This is possibly the most frustrating thing about programming; no matter how good your code or how well you understand your own logic, a million things you are unaware of can break it in ways that are near darn near impossible to track down and figure out.

The TLDR is: Neither my code nor the engine had a bug, but something weird seems have come from some asset of other.

EDIT: I don’t think it was any of the assets – dragging scripts onto the inspector was also causing two copies to appear at once, and what fixed the problem was uninstalling and reinstalling Unity, so something must have gotten corrupted somehow.