# SetGlobalFloat

> Sets a global float property for all shaders.

## Definition

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

## SetGlobalFloat(string, float)

Sets a global float property for all shaders.

```csharp
public static void SetGlobalFloat(string name, float value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)):&#x20;

### Remarks

Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in Properties block).

Usually this is used if you have a set of custom shaders that all use the same "global" float (for example, density of some custom fog type). Then you can set the global property from script and don't have to setup the same float in all materials.

Additional Resources: [Shader.SetGlobalColor](/engine/6000.0/script-reference/unityengine/shader/setglobalcolor.md), [Shader.SetGlobalTexture](/engine/6000.0/script-reference/unityengine/shader/setglobaltexture.md); [Material](/engine/6000.0/script-reference/unityengine/material.md) class, [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md).

The following example sets the global float property `_MyFloat` to `1` in all shaders.

### Examples

```csharp
using UnityEngine;

public class SetGlobalFloatExample : MonoBehaviour
{
    void Start()
    {
        Shader.SetGlobalFloat("_MyFloat", 1.0f);
    }
}
```

## SetGlobalFloat(int, float)

Sets a global float property for all shaders.

```csharp
public static void SetGlobalFloat(int nameID, float value)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The name ID of the property retrieved by [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)):&#x20;

### Remarks

Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in Properties block).

Usually this is used if you have a set of custom shaders that all use the same "global" float (for example, density of some custom fog type). Then you can set the global property from script and don't have to setup the same float in all materials.

Additional Resources: [Shader.SetGlobalColor](/engine/6000.0/script-reference/unityengine/shader/setglobalcolor.md), [Shader.SetGlobalTexture](/engine/6000.0/script-reference/unityengine/shader/setglobaltexture.md); [Material](/engine/6000.0/script-reference/unityengine/material.md) class, [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md).

The following example sets the global float property `_MyFloat` to `1` in all shaders.

### Examples

```csharp
using UnityEngine;

public class SetGlobalFloatExample : MonoBehaviour
{
    void Start()
    {
        Shader.SetGlobalFloat("_MyFloat", 1.0f);
    }
}
```
