Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetFloat

Sets the value of a float property exposed in the blackboard.
Read time 1 minuteLast updated 6 days ago

Definition

SetFloat(int, float)

Sets the value of a float property exposed in the blackboard.
public void SetFloat(int nameID, float f)

Parameters

nameID

The ID of the property. This is the same ID that Shader.PropertyToID returns.

The new float value.

Remarks

Automatically changes overridden state for this property to true.

Examples

using UnityEngine;using UnityEngine.VFX;class SetFloatExample : MonoBehaviour{ [SerializeField] VisualEffect m_Vfx; [SerializeField] float m_Frequency = 1f; [SerializeField] float m_Phase = 0f; static readonly int k_MyValuePropertyNameID = Shader.PropertyToID("MyValueProperty"); void Update() { m_Vfx.SetFloat(k_MyValuePropertyNameID, Mathf.Cos(Time.time * m_Frequency + m_Phase)); }}

SetFloat(string, float)

Sets the value of a float property exposed in the blackboard.
public void SetFloat(string name, float f)

Parameters

name

The name of the property.

The new float value.

Remarks

Automatically changes overridden state for this property to true.

Examples

using UnityEngine;using UnityEngine.VFX;class SetFloatExample : MonoBehaviour{ [SerializeField] VisualEffect m_Vfx; [SerializeField] float m_Frequency = 1f; [SerializeField] float m_Phase = 0f; static readonly int k_MyValuePropertyNameID = Shader.PropertyToID("MyValueProperty"); void Update() { m_Vfx.SetFloat(k_MyValuePropertyNameID, Mathf.Cos(Time.time * m_Frequency + m_Phase)); }}