Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by imnickb · May 09, 2012 at 02:46 PM · positionscaleslideronguidimensions

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 ();
 }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bompi88 · May 09, 2012 at 03:41 PM 0
Share

We have to see parts of your code to know how to help you.

avatar image imnickb · May 09, 2012 at 05:24 PM 0
Share

Crap, I'm sorry! I forgot to paste it in here before I ran out the the door. I'll try to delete the questions and re-ask it later with the script attached. Sorry!

avatar image bompi88 · May 09, 2012 at 05:35 PM 0
Share

hehe.. okey, understand. I think you can edit your question, ins$$anonymous$$d of deleting it and re-ask it. Could be easier ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by imnickb · May 16, 2012 at 01:08 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change particle system scale value with script 1 Answer

How to rotate/scale a prefab instance from the GUI? 2 Answers

postion scale and rotation greyed out and not working 1 Answer

How to fix game objects on surface of a cube when scaling the height?,Change position and scale with one slider? 0 Answers

slider inside window function not inside onGui 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges