unity object disappearing when looking at axis code example

Example: unity sprite disappears when using transform.lookat

// Do not use "transform.LookAt" for 2D 
// Instand use something similar to this

public static void LookAt2D(this Transform transform, Vector2 target)
{
    var direction = target - (Vector2)transform.position; // Get the direction
    var angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; // Convert to angle
    transform.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward); // Finally rotate the GameObject
}