Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by CalledToGaming · Apr 25, 2010 at 06:50 AM · guisliderhorizontal-slider

GUI Sliders in the same script. Question (Js.)

I'm working on an options menu for my game. For testing sake, (for my testers) I'm bringing in sliders to adjust things like player movement speed, jump speed, etc.

The problem I'm having is that when I have 2 sliders in the same script, only one of them reacts no matter which one I try to use. In this case, the "Player Speed" slider only works. When I click on the "Jump Height" slider, and try to drag it, it moves the "Player Speed" Slider Instead.

Any help would be appreciated, and I apologize for my recent uprising in questions. I've viewed, and reviewed the GUI Documentation resources and I'm still at a loss here. I'm finally making progress and I don't want to stop now!

var menu : boolean;

function Awake() { DontDestroyOnLoad(this); } function Start() { menu = false; }

function OnGUI() {if(menu == false) return; GUI.Box (Rect (10, 10,Screen.width - 20,Screen.height - 20), "Options");

         //The problem is the two sliders below!!
 //Player Speed Slider
 GUI.Label (Rect (25,25,100,150),"Player Speed");
 FPSMove.speed = GUI.HorizontalSlider (Rect(25,50,100,150), FPSMove.speed, 10.0,50.0);
 //Jump Height Slider
 GUI.Label (Rect (25,75,100,150),"JumpHeight");
 FPSMove.jumpSpeed = GUI.HorizontalSlider (Rect(25,100,100,150), FPSMove.jumpSpeed, 10.0,20.0);
         //The Problem is the two sliders above!!

 //Resume Game
 if(GUI.Button (Rect ( 300,Screen.height -75, 100,50),"Resume"))

{ menu = false; } //Return to Main Menu if(GUI.Button (Rect (400, Screen.height -75, 100,50),"Main Menu")) { Application.LoadLevel ("MainMenu"); } //Quit to Desktop if(GUI.Button(Rect (500, Screen.height - 75, 100,50),"Quit")) { Application.Quit(); } }

function Update() { //Toggle Options Menu On if(Input.GetButtonDown("O")) { menu = true; } //Exit Options Menu if(Input.GetButtonDown("Esc")) { menu = false; } }

Sorry for the mess that is this script. I'm trying to keep it as organized as I can, But trying to figure this scripting problem out is causing a little chaos.

Thanks again for any help.

Comment
Add comment
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

1 Reply

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

Answer by StephanK · Apr 25, 2010 at 01:04 PM

You specified 150 as height for the slider. This makes the slider area so big, that it actually overlaps the area of the slider below. It seems that in this case Unity only processes the input for the element that was created first.

In short: adjust the height of the sliders to a sensible value (25 might work...). If you'd use GUILayout you would avoid this problem automagically. ;)

Comment
Add comment · Show 1 · 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
avatar image CalledToGaming · Apr 25, 2010 at 08:25 PM 0
Share

Thanks, That solved it. I appreciate the help. It's actually pretty often that I make mistakes like this. You'd think by now that I'd start catching these errors myself.

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

No one has followed this question yet.

Related Questions

'MouseLook.sensitivityX' is inaccessible due to its protection level. 2 Answers

What is frame, How OnGuI is called every frame? 2 Answers

What can i use besides an event current 1 Answer

What Am I Doing Wrong? Variable Names 3 Answers

How do I add NPCs? 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