- Home /
how to control SMOOTHNESS via GUI slider?! It's not working...pls help!
hello world
I've been trying to use a GUI slider to control 'smoothness' of an object but It just doesn't work.
here's my latest atempt:
 using UnityEngine;
 using UnityEngine.UI;  
 using System.Collections;
 
 public class metalicslider : MonoBehaviour {
 public GameObject metasphere; // object that will be affected
 public Slider sldfind;
  Renderer sphrend;
 
 
 
     // Use this for initialization
     void Start () {
         sphrend = metasphere.GetComponent<Renderer>();
         sphrend.material.shader = Shader.Find ("Standard");
 
         
             }
 
 
 
 
     // Update is called once per frame
     void Update (){
         sphrend.material.EnableKeyword ("_SPECCGLOSSMAP");
         sphrend.material.SetFloat ("_SPECCGLOSSMAP", sldfind.value);
 
     }
 }
 
I checked the documentation, tried this one too, but no cookie
 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     public Renderer rend;
     void Start() {
         rend = GetComponent<Renderer>();
         rend.material.shader = Shader.Find("Specular");
     }
     void Update() {
         float shininess = Mathf.PingPong(Time.time, 1.0F);
         rend.material.SetFloat("_Shininess", shininess);
     }
 }
please, help me!
Answer by ArturoSR · Sep 08, 2016 at 07:39 PM
@kbr0n Hello there.
OK, here is the way to do that:  
 
So, as you can see that's how could be done, I recommend to you to download the shaders accordingly to your unity version to check the properties you can controlling it by script, cheers.
hi, thank you so much!
I only had to make a $$anonymous$$or tweak and it worked!
it was not _Glossiness, but _Gloss$$anonymous$$apScale
Your answer
 
 
             Follow this Question
Related Questions
OnGUI sliders only accept float? C# 2 Answers
Display actual number of bullets 1 Answer
Set Slider value but don't trigger On Value Changed 4 Answers
Horizontal slider won't work 1 Answer
Distribute terrain in zones 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                