Having trouble positiong UI sliders using OnGui

I’ve been working on a project that’s almost done except that I can’t get the UI elements to be in the right position. I’m using OnGui to great a horizontal slider. In the editor, I have the dimensions set to Web 640x960 and everything looks good. Then, when I make a build for the web using the same dimensions, my slider is too far to the left. Also, the slider’s scale doesn’t appear to match the scale of the objects in the rest of the scene, although the objects all look good in the editor when I’m using 640x960.

UI is proving to be one of the more difficult tasks in the project. I’ve read the documentation, and I think what I’m doing should work but I’m stumped.

var hSliderValue : float = 0.0;
var hthumbStyle : GUIStyle;
var hsliderStyle : GUIStyle;

function Awake(){
	hSliderValue = 10.0;
}

function Update(){
	AudioListener.volume = hSliderValue/10.0;
	fl_time_left = hSliderValue;
}

function OnGUI () {
	GUILayout.BeginArea (Rect (Screen.width/20+9, Screen.height/2+254, 376.5, 31.5));
	hSliderValue = GUILayout.HorizontalSlider (hSliderValue, 0.0, 10.0,hsliderStyle,hthumbStyle);
	GUILayout.EndArea ();
}

So this was a stupid mistake on my part… Although I had resized the scene view window to be as large as possible, I still had the project and hierarchy views at the bottom of the screen, thus the scene window resolution was misleading and not exactly what it should have been. I moved the hierarchy and project views and clicked the “maximize on play” selection in the game view and then placed my UI and everything was positioned correctly.

So maybe it was a stupid problem, but I was stumped!

1-Make sure inspector and project views (and any other windows) are not keeping you from maximizing the scene view.
2-Click “Maximize on Play” to make sure the game view is also at the right resolution.