Local based rotation

I am not talking about simply setting the transform.localEulerAngles. But, when you use the rotation manipulator inside of the editor, and you set it to local, when you rotate something, it rotates exactly as expected. However, if you try and do a local rotation using transform.localEulerAngles, it still looks like a global rotation.

This is hard to explain, so you may just have to try this yourself to understand what I am getting at.

Say I want to rotate in the + local y. If I set localEulerAngles in code, because of the way Vector3s work, you have to set all 3. But, if you look at a local rotation in the editor, simply rotating in the local y changes more than just the y rotation. So how do I calculate the same type of local rotation?

Just so you can see my code, here is the rotation code. I am basically trying to create a rotation manipulator in game.

//The local euler angles
float x = startingRotation.x;
			float y = startingRotation.y;
			float z = startingRotation.z;
			
			Vector3 manipPos = ManipulatorCamera.WorldToScreenPoint(this.transform.position);
			
			float o = Vector3.Distance(Input.mousePosition, positionLastFrame);
			float a = Vector3.Distance(positionLastFrame, manipPos);
			
			float angle = Mathf.Rad2Deg*Mathf.Atan(o/a)*GetDirection(manipPos,Input.mousePosition,positionLastFrame);
			
			totalRotation += angle;
			
			switch(selectedManipulator.name)
			{
				case "RotationRingX" :
					x += totalRotation;
					break;
				case "RotationRingY" :
					y += totalRotation;
					break;
				case "RotationRingZ" :
					z += totalRotation;
					break;
			}
			
			Debug.Log(x + " " + y + " " + z);
			
			Managers.SelectionManager.SelectedSmartPart.transform.localEulerAngles = new Vector3(x,y,z);
			
			positionLastFrame = Input.mousePosition;

As far as i know, Unity handle the rotation of the object using Quaternion and the displayed information is actually a conversion from the Quaternion rotation to the EulerAngles. If you need the values to do something, I’d suggest you to store the desired rotation in a Vector3 property and update the localEulerAngles in the “set” method.