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!