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 ();
}