Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

how to control "SMOOTHNESS" via GUI slider?! SOLVED!

Discussion in 'Getting Started' started by kbr0n, Sep 8, 2016.

  1. kbr0n

    kbr0n

    Joined:
    Aug 28, 2016
    Posts:
    24
    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:

    Code (csharp):
    1.  
    2.   using UnityEngine;
    3.   using UnityEngine.UI;  
    4.   using System.Collections;
    5.    
    6.   public class metalicslider : MonoBehaviour {
    7.   public GameObject metasphere; // object that will be affected
    8.   public Slider sldfind;
    9.   Renderer sphrend;
    10.      
    11.      // Use this for initialization
    12.      void Start () {
    13.        sphrend = metasphere.GetComponent<Renderer>();
    14.        sphrend.material.shader = Shader.Find ("Standard");
    15.          
    16.          }
    17.    
    18.         // Update is called once per frame
    19.      void Update (){
    20.        sphrend.material.EnableKeyword ("_SPECCGLOSSMAP");
    21.        sphrend.material.SetFloat ("_SPECCGLOSSMAP", sldfind.value);
    22.    
    23.      }
    24.   }
    25.    
    26.  

    I checked the documentation, tried this one too, but no cookie
    Code (csharp):
    1.  
    2.   using UnityEngine;
    3.   using System.Collections;
    4.    
    5.   public class ExampleClass : MonoBehaviour {
    6.   public Renderer rend;
    7.   void Start() {
    8.   rend = GetComponent<Renderer>();
    9.   rend.material.shader = Shader.Find("Specular");
    10.   }
    11.   void Update() {
    12.   float shininess = Mathf.PingPong(Time.time, 1.0F);
    13.   rend.material.SetFloat("_Shininess", shininess);
    14.   }
    15.   }
    16.  
    please, help!
     
  2. kbr0n

    kbr0n

    Joined:
    Aug 28, 2016
    Posts:
    24
    I figured it out!
    the name of the property is "_GlossMapScale" that's the one which controls the "Smoothness" slider
     
    JoeStrout likes this.