As long as the sun is only rotating about a single axis (the x axis for instance) this will work. There are 24 hours in a day and 360 degrees in a circle. Assuming that midnight is when the sun is pointing straight up (away from the world) and noon is when it is pointing straight down (towards the world), we have that 0 hours corresponds to 0 degrees (0 being straight up) and 12 hours corresponds to 180 degrees. The math itself is then quite simple; you were almost there:
Hour = rotation/360 * 24
Or in Unityscript:
hour = transform.eulerAngles.x / 360.0f * 24.0f;
Just make sure to check that 0 degrees does in fact mean that the sun is pointing straight up. If not, you’ll need to adjust the calculation.