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 · Apr 03, 2012 at 09:38 PM · uiguiaudiosliderart

Vertical Slider - Using different art?

Currently I have a vertical slider in a scene controlling the volume of audio playing and it works quite well. I'm using the Unity GUI for the slider and it's not incredibly attractive. I know you can customize the look of the GUI to an extent, but is it possible to use art assets for the slider? Like maybe a 2D image of a slider and another 2D image of the track that it would run on? Sorry for what's probably an ignorant question, but I haven't found much info on how to do this. Does anyone have any tips? Should I not use the GUI at all for this and just pass a value of where the slider image or model currently is and use that to set the volume?

Thanks for the help!

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 syclamoth · Apr 03, 2012 at 11:11 PM 0
Share

Look up GUIstyles in the reference manual. That's what you need, here.

avatar image imnickb · Apr 04, 2012 at 12:39 AM 0
Share

Thanks for pointing me in the right direction!

http://unity3d.com/support/documentation/Components/class-GUIStyle.html

I also read the page describes the different GUIStyle parameters you can set for the sliders. Here are the parameters I was looking for:

slider The GUIStyle to use for displaying the dragging area. If left out, the horizontalSlider style from the current GUISkin is used.

thumb The GUIStyle to use for displaying draggable thumb. If left out, the horizontalSliderThumb style from the current GUISkin is used.

I'm having trouble figuring how to point these two parameters to the image I want to use. Does anyone have any suggestions? This is my first go at using the Unity GUI. Everything I've read about people trying to use images for the thumbs and sliders was about how they couldn't figure it out.

1 Reply

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

Answer by imnickb · Apr 04, 2012 at 12:51 PM

After some trial and error and found an answer. In case anyone with the same issue finds this question, here's what I found:

Add variables for the GUIstyles you plan to use.

 var vthumbStyle : GUIStyle;
 var vsliderStyle : GUIStyle;

Find the script with GUI Styles you're using in the scene.

Assign the images you want to use for the sliders to Background under Normal.

In your script where you create the sliders, reference the GUI Style you created.

 function OnGUI () {
     vSliderValue = GUI.VerticalSlider (Rect (327, 125, 15, 300), vSliderValue, 10.0, 0.0,vsliderStyle,vthumbStyle);
 }

The next part is what was kind of confusing because I didn't see it in the documentation anywhere. In the GUI Style you're using in the inspector, you need to add the dimensions of the images you're using under Fixed Height and Fixed Width. It also helped me to make the images the same height, so that the Thumb and Slider line up easily with each other. I hope this helps someone!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Volume Slider - Play a sound after modifying slider value and releasing the mouse 1 Answer

How do you get Old OnGUI Scripts to work with the New UI Scrollbars? 0 Answers

UI Slider - making the touch area for slide larger than the UI image handle 2 Answers

Audio Horizzontal slider problem. 1 Answer

PlayerPrefs not saving slider value & audio 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