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
0
Question by fireArchMage23 · Nov 27, 2015 at 10:24 AM · shaderslidersyntaxproperty

Customize slider in Shader

I'm working on a shader that has some properties that are range types. I want to add a input box to the slider so the current value of the slider can be seen while using the slider. How would one do this? This is an example of a property:

_Luminocity ("Luminocity", range (0.0, 5.0)) = 1

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by JonathanCzeck · Dec 06, 2015 at 06:10 AM

What you're describing is the default behavior for a range property. I just tried it in 5.2.2p4 and 5.3f2 to confirm. What are you seeing?

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 fireArchMage23 · Dec 07, 2015 at 01:36 AM 0
Share

I only see the slider but no input box to show current value (or if I wanted to set a specific value).

avatar image
0

Answer by tanoshimi · Dec 06, 2015 at 09:16 AM

Define a custom material editor: http://docs.unity3d.com/460/Documentation/Manual/SL-CustomMaterialEditors.html

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
avatar image
0

Answer by viju · Jan 28, 2016 at 01:30 PM

You can do this by adding a "Text" under the "Handle Slide Area" > "Handle" of the Slider. Please see my custom slider below. I have added a text called "Charge Value"

I have named my Slider as "Battery". It uses a Battery.png image as background. You can easily create the image using PowerPoint or any other application. Then I have created two more images: one for the red indication when battery charge is low and another for the regular indication.

You can slide the charge indicator to increase or decrease the charge smoothly. I have also added a text field to indicate the charge value in numbers. Please see the images below.

The Slider Script is attached to the Panel (Canvas) in which the Battery Slider resides. The variables are assigned as shown in the images below. The complete script is below.

 using UnityEngine;
 using UnityEngine.UI;
 
 public class SliderScript : MonoBehaviour
 {
     public Slider battery;
     public Image charge;
     public Text chargeValue;
     public Sprite indication, redIndication;
 
     // Use this for initialization
     void Start ()
     {
         // Indicate red if the charge is less than 10
         if (battery.value < 10)
             charge.GetComponent<Image> ().sprite = redIndication;
         chargeValue.text = ((int)battery.value).ToString ();
     }
 
     public void OnSlide ()
     {
         if (battery.value < 10) {
             charge.GetComponent<Image> ().sprite = redIndication;
         }
         if (battery.value >= 10 && battery.value < 50) {
             charge.GetComponent<Image> ().sprite = indication;
             charge.color = new Color32 (255, 200, 0, 255);
         }
         if (battery.value >= 50) {
             charge.GetComponent<Image> ().sprite = indication;
             charge.color = new Color32 (51, 255, 0, 255);
         }
         chargeValue.text = ((int)battery.value).ToString ();
     }
 
 }

Slider Value


slide-value.png (124.6 kB)
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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Material doesn't have a color property '_Color' 4 Answers

Changing shader based on graphics settings 1 Answer

Shader Graph Matrix4x4 Convert to Property 0 Answers

Change value of a shader propertie using a Slider 1 Answer

Unity 5 standard shader problems ? (Resolved) 1 Answer


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