SetGlobalFloat
Sets a global float property for all shaders.
Read time 2 minutesLast updated 11 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
SetGlobalFloat(string, float)
Sets a global float property for all shaders.
public static void SetGlobalFloat(string name, float value)
Parameters
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, Shader.SetGlobalTexture; Material class, ShaderLab documentation.
The following example sets the global float property to in all shaders.
_MyFloat1Examples
using UnityEngine;public class SetGlobalFloatExample : MonoBehaviour{ void Start() { Shader.SetGlobalFloat("_MyFloat", 1.0f); }}
SetGlobalFloat(int, float)
Sets a global float property for all shaders.
public static void SetGlobalFloat(int nameID, float value)
Parameters
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, Shader.SetGlobalTexture; Material class, ShaderLab documentation.
The following example sets the global float property to in all shaders.
_MyFloat1Examples
using UnityEngine;public class SetGlobalFloatExample : MonoBehaviour{ void Start() { Shader.SetGlobalFloat("_MyFloat", 1.0f); }}