# How to change two rotation axes in Unity without affecting the third?

I have a GameObject in Unity and I need to change its X and Z rotation without doing anything with the Y, as that would mess up everything.
Note that this sets the Y rotation to 0 and I don't want that (I want it to let it be be what it already is), so this isn't any good:

gameObject.transform.rotation = Quaternion.Euler(someNewAngle, 0f, someNewAngle);


What should I do?

Just take the previous value of the Y rotation using transform.rotation.eulerAngles.
var yRotation = gameObject.transform.rotation.eulerAngles.y;