Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

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

Material.GetFloat

GetFloat(propertyName: string): float;
float GetFloat(string propertyName);
def GetFloat(propertyName as string) as float
GetFloat(nameID: int): float;
float GetFloat(int nameID);
def GetFloat(nameID as int) as float

Description

Get a named float value.

	function Start() {
		renderer.material.shader = Shader.Find("Specular");
		print(renderer.material.GetFloat("_Shininess"));
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        renderer.material.shader = Shader.Find("Specular");
        print(renderer.material.GetFloat("_Shininess"));
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		renderer.material.shader = Shader.Find('Specular')
		print(renderer.material.GetFloat('_Shininess'))