I have a plane that I want to adjust my gameobject to while keeping the ability to rotate around the (new) local Y-axis. Therefore I calculated the planes normal (curUp) and planned on rotating the transform.up towards it.
Quaternion rot = Quaternion.FromToRotation(transform.up, curUp);
transform.Rotate(rot.eulerAngles.x, 0, rot.eulerAngles.z, Space.World);
That does not work as intended obviously, since I’m setting the global y axis to 0. However every attempt to transform the rotation into local space and setting the local y rotation to 0 results in a mess. What’s the correct way of doing this in Unity?