Rigidbody2D velocity in random direction with exceptions

Hey Guys,
so I’m trying to recreate Pong and want the ball to spawn in the middle with a desired start speed. The ball should start being faced in a random direction. However it should not face 0-30, 150-210 and 330-360 degrees. How can I do these exceptions? Here’s my code:

using UnityEngine;

public class Ball : MonoBehaviour {

	public float startSpeed;

	private Rigidbody2D rb;

	void Awake () 
	{
		rb = GetComponent<Rigidbody2D> ();
		rb.velocity = Random.onUnitSphere * startSpeed;
	}
}

One straight forward way is to just calculate a random angle for one side and than randomly choose a side:

float angle = Random.Range(30f, 150f) + Random.Range(0,2) * 180f;

This angle will be in the range you specifed. To turn it into a direction vector, just use:

float radAngle = angle * Mathf.Deg2Rad;
Vector2 dir = new Vector2(Mathf.Cos(radAngle), Mathf.Sin(radAngle));

This of course assumes that 0° is the usual mathematical convention of “right”. So 90° is “up”, 180° is “left” and 270° is “down”.