# SetFloat

> Sets a named float value.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## SetFloat(string, float)

Sets a named float value.

```csharp
public void SetFloat(string name, float value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Property name, e.g. "\_Glossiness".**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Float value to set.

### Remarks

When setting values on materials using the Standard Shader, you should be aware that you may need to use [Material.EnableKeyword](/engine/6000.0/script-reference/unityengine/material/enablekeyword.md) to enable features of the shader that were not previously in use. For more detail, read [Accessing Materials via Script](/engine/6000.0/manual/materials-and-shaders/materials/accessing-via-script.md).

Additional Resources: [Material.GetFloat](/engine/6000.0/script-reference/unityengine/material/getfloat.md), [Materials](/engine/6000.0/manual/materials-and-shaders/materials.md), [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md), [Properties in Shader Programs](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-change-properties/sl-properties-in-programs.md).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    Renderer rend;

    void Start()
    {
        rend = GetComponent<Renderer> ();

        // Use the Specular shader on the material
        rend.material.shader = Shader.Find("Specular");
    }

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

## SetFloat(int, float)

Sets a named float value.

```csharp
public void SetFloat(int nameID, float value)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Property name ID, use [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md) to get it.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Float value to set.

### Remarks

When setting values on materials using the Standard Shader, you should be aware that you may need to use [Material.EnableKeyword](/engine/6000.0/script-reference/unityengine/material/enablekeyword.md) to enable features of the shader that were not previously in use. For more detail, read [Accessing Materials via Script](/engine/6000.0/manual/materials-and-shaders/materials/accessing-via-script.md).

Additional Resources: [Material.GetFloat](/engine/6000.0/script-reference/unityengine/material/getfloat.md), [Materials](/engine/6000.0/manual/materials-and-shaders/materials.md), [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md), [Properties in Shader Programs](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-change-properties/sl-properties-in-programs.md).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    Renderer rend;

    void Start()
    {
        rend = GetComponent<Renderer> ();

        // Use the Specular shader on the material
        rend.material.shader = Shader.Find("Specular");
    }

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