private SetFloat ( int nameID, float value ) : void | ||
nameID | int | |
value | float | |
return | void |
// Get the material component of the object Material material = gameObject.GetComponent().material; // Set the transparency property to 0.5 material.SetFloat("_Transparency", 0.5f);
// Get the material component of the object Material material = gameObject.GetComponentThis example sets two properties (_DistortionStrength and _DistortionFrequency) in the material, creating a distortion effect on the object. Package Library: UnityEngine.CoreModule().material; // Set the distortion strength property to a random value float distortionStrength = Random.Range(0f, 1f); material.SetFloat("_DistortionStrength", distortionStrength); // Set the distortion frequency property to a constant value material.SetFloat("_DistortionFrequency", 0.5f);