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 baroku · Jun 24, 2014 at 01:30 PM · sliderborderextend

How to extend HorizontalSlider?

Hi!

I have a horizontal Slider with fixed width 300. The Problem is, that my SliderThumb cannot be moved to the end. It seems like only the slider texture is 300.

I attach screenshot because of my english its hard to explain the case.

http://imgur.com/TfijIaN

As you can see on the screenshot, the volume slider cannot be moved forward to the right. It looks like its border is set up somwhere in the middle.

Im using custom GUISkin. Where can i find the option to extend the slider? Can this be made in GUISkin, or in my script?

using UnityEngine; using System.Collections; public class Options : MonoBehaviour { //these variables are only here because it is cheaper to access a value from memory instead of through a static class private float screenHeight; private float screenWidth; private float buttonHeight; private float buttonWidth; public GUISkin guiSkin; private float mySlider = 1.0f; // Use this for initialization void Start () { screenHeight = Screen.height; screenWidth = Screen.width; buttonHeight = screenHeight * 0.15f; buttonWidth = screenWidth * 0.3f; } void OnGUI() { //in order to use a delegate we just call it like a function. Simple! GUI.skin = guiSkin; options(); } float LabelSlider (Rect screenRect, float sliderValue, float sliderMaxValue, string labelText) { GUI.Label (screenRect, labelText); // <- Push the Slider to the end of the Label screenRect.x += screenRect.width; sliderValue = GUI.HorizontalSlider (screenRect, sliderValue, 0.0f, sliderMaxValue); return sliderValue; } //mainMenu only has two buttons in the version, one to play the game, and one to quit the game void options() { mySlider = LabelSlider (new Rect (480, 200, 100, 20), mySlider, 300.0f, "VOLUME"); if(GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.4f, buttonWidth, buttonHeight), "BACK")) { Application.LoadLevel("menu"); } } }

Im very new to Unity, so maybe its stupid question, but I will apreciate every answer.

Comment
Add comment · Show 2
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 Nerevar · Jun 24, 2014 at 01:55 PM 0
Share

I tried your code, it seems I don't have any issues, the sliderThumb can go till the end. Can you maybe show us where you declare mySlider and more important the GUISkin part concerning the horizontal slider ?

avatar image baroku · Jun 24, 2014 at 02:22 PM 1
Share

Thank you for you answer! Here the screenshot where i set the fixed height and width.

Here is the Slider GUISkin settings:

link text

And here I attach Thumb GUISkin settings as well, maybe here something must be changed:

link text

mySlider is declared at the beginning of the code, it looks pretty simple:

private float mySlider = 1.0f;

The only thing I actually changed is Fixed Width of Slider and the Fixed Width and Fixed Height of the Thumb.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Nerevar · Jun 24, 2014 at 02:44 PM

Okay, I think I got it :p

when you make your slider line 32 you set a wrong size, you have to decide whether you set the width parameter in script or in your custom skin.

two solutions:

1) Set the Slider fixed width to zero in the Custom skin

2) Retreive the fixed parameter from it and use it when you create your slider:

 mySlider = LabelSlider (new Rect (480, 200, guiSkin.horizontalSlider.fixedWidth , 20), mySlider, 300.0f, "VOLUME");
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 Nerevar · Jul 07, 2014 at 03:38 PM 0
Share

is it solved?

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

2 People are following this question.

avatar image avatar image

Related Questions

Adjust Brightness Screen 3 Answers

make checkpoint in sliderbar 0 Answers

Slider UI rotate image/sprite 1 Answer

Got stuck trying to extend UnityPlayerActivity following example in Unity documentation. 1 Answer

Extend a line between two Vectors by a distance 0 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