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 NPS · May 05, 2014 at 11:12 AM · inspectorvariablesslider

Inspector slider value?

Shader variables that represent range (e.g. Range(0.5, 1.3)) can be set in the Inspector using a slider. The problem is - the slider doesn't show the actual value (given by a number) anywhere. I've set the shader variables in the Inspector so that my model looks nice but now I need to know what exact values the variables have so I can use them in code.

How the hell do I retrieve the exact values from variable sliders?

Edit: Look at this screen:

alt text

How do I know what exact values do Shininess and Grad have?

bla.png (11.5 kB)
Comment
Add comment · Show 6
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 Professor Snake · May 05, 2014 at 12:04 PM 0
Share

I'm not sure what you are asking for is all that doable. but you can change the variable type from Range(0.5, 1.3) to Float.

avatar image NPS · May 05, 2014 at 12:28 PM 0
Share

I can't - it's a built-in shader. :P Besides, sometimes I DO want to have Range ins$$anonymous$$d of float.

avatar image Professor Snake · May 05, 2014 at 12:38 PM 0
Share

Temporarily changing it to a Float would retain the Range's value though, so you would be able to see it. Though i suppose this isn't all that much of a solution for built-in shaders.

avatar image robertbu · May 05, 2014 at 01:49 PM 0
Share

You can use GetFloat() to get the current value from the material in code. An editor extension would allow you to select objects and display the value, or you could just output it in a Debug.Log() statement.

avatar image NPS · May 05, 2014 at 02:02 PM 0
Share

Am I to understand, that there is no possibility to check it without writing special scripts and "debugging" Unity? :/ As for the editor extension - how do I do that (any link)?

Show more comments

2 Replies

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

Answer by Wolfram · May 05, 2014 at 03:54 PM

You can switch the Inspector to the "Debug" view. All visible float properties of the shader will then be listed in the SavedProperties->Floats array, by property name and current value. You can use the same trick to set these properties to explicit values via the Inspector interface (as opposed to a script).

Comment
Add comment · Show 2 · 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 Markus__T · Jul 01, 2014 at 12:19 PM 0
Share

Excellent simple solution! Thanks.

avatar image NPS · Jul 01, 2014 at 12:29 PM 1
Share

Yes, that's what I was looking for. Although the same functionality should be available for floats in Normal view, I$$anonymous$$O. On a different subject, now I see you posted that looooong time ago but the system never notified me. :( But now it's accepted and thank you.

avatar image
1

Answer by robertbu · May 05, 2014 at 02:44 PM

Here is a quick editor script as an example. Put it in the Editor folder of your project. Pick the 'ShowSliderValues' from the Window menu. You have to hard code the property that you are interested in. Fortunately shaders tend to use the same property names:

 using UnityEngine;
 using UnityEditor;
 using System.Collections.Generic;
 
 public class ShowSliderProps : EditorWindow {
 
     [MenuItem("Window/ShowSliderValues")]
     public static void ShowWindow() {
         EditorWindow.GetWindow(typeof(ShowSliderProps));
     }
 
     Transform curr;
 
     void OnGUI() {
         curr = Selection.activeTransform;
 
         GUILayout.Label("Shininess: "+GetSlideProp("_Shininess"));
         GUILayout.Label("Grad"+GetSlideProp("_Grad"));
         GUILayout.Label("Blend"+GetSlideProp("_Blend"));
     }
     
     float GetSlideProp(string prop) {
 
         if (curr == null) {
             return -1.0f;
         }
 
         Renderer rend = curr.GetComponent<Renderer>();
         if (rend == null) {
             return -1.0f;
         }
 
         if (!rend.material.HasProperty(prop)) {
             return -1.0f;
         }
 
         return rend.material.GetFloat(prop);
     }
 }

Note that if you are playing with the slider, you need to change the focus to the window this editor script brings up in order to see the changed value.

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 NPS · May 05, 2014 at 03:36 PM 0
Share

Thx for writing the script. I'll wait some time to see if anyone has any answer that doesn't use a script. If not, I'll accept this one.

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

23 People are following this question.

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

Related Questions

How to change the way the inspector shows variables Javascript 1 Answer

Can I use custom inspector widgets, such as a slider for a floating point property, without writing a custom editor? 3 Answers

Inspector defined variable wiped away when game is built. 2 Answers

The box for entering a variable's value in the inspector is not where it should be. 0 Answers

Do I have to change the value of a pubilic variable in the script even if I have already changed the value in the inspector variable? 3 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