Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Material.SetFloat

Switch to Manual
public function SetFloat(propertyName: string, value: float): void;
public function SetFloat(nameID: int, value: float): void;

Parameters

Description

Set a named float value.

var rend: Renderer;

function Start () { rend = GetComponent.<Renderer>(); // Use the Specular shader on the material rend.material.shader = Shader.Find("Specular"); }

function Update () { // Animate the Shininess value var shininess : float = Mathf.PingPong(Time.time, 1.0); rend.material.SetFloat("_Shininess", shininess); }