Mystify FX allows you to modify effect parameters at runtime through scripting. This feature is useful for creating dynamic effects and customizing user interactions. Below is a basic example demonstrating how to adjust the rainSpeed parameter of a profile associated with the effect:
using UnityEngine;
using MystifyFX;
public class RainSpeed : MonoBehaviour {
public MystifyEffect mystify;
void Start () {
// Get the MystifyEffect component attached to this GameObject
mystify = GetComponent<MystifyEffect>();
}
void Update () {
// Change the rain speed by pressing keys 1 or 2
if (Input.GetKeyDown(KeyCode.Alpha1)) {
mystify.profile.rainSpeed = 0.01f; // Low speed
mystify.UpdateMaterialProperties(); // Apply the changes
}
if (Input.GetKeyDown(KeyCode.Alpha2)) {
mystify.profile.rainSpeed = 10; // High speed
mystify.UpdateMaterialProperties(); // Apply the changes
}
}
}
Important Note
UpdateMaterialProperties(): After modifying the values in the profile, you must call this method to ensure the changes are correctly reflected in the effect’s material.- Use sharedProfile instead of profile to avoid instantiating the profile (useful if you want to modify a shared profile among objects)