unity rotation to vector3 code example

Example 1: 2d rotation unity

// Rotation scripting with Euler angles correctly.
// Store the Euler angle in a class variable, and only use it to
// apply it as a Euler angle, but never rely on reading the Euler back.
        
float x;
void Update () 
    {
        x += Time.deltaTime * 10;
        transform.rotation = Quaternion.Euler(x,0,0);
    }

Example 2: unity rotate vector3

Quaternion rotation = Quaternion.Euler(x,y,z);
Vector3 myVector = Vector3.one;
Vector3 rotateVector = rotation * myVector;