IssuesCategory: MagioCan't change exposed parameter on runtime via code
A. A. KARAGEORGIOU asked 1 month ago

Hey there, love using your asset and i need your dear help,

I want to be able to control a certain parameter of the effect that is currently playing, in our example im referring to the FireParticleSize of the Flame WIld effect.
Even though im clearly finding the parameter on code, the parameter’s value is not being changed. I tried both changing the instantiated prefab and the effectPrefab in the MagioObjectEffect script but to no avail. 
Is there something else i must take into account when i want to change the value of the exposed parameters? Here is the relevant code for reference:
// Find the “Effects” child transform under MagioEngine._instance.gameObject
Transform effectsTransform = MagioEngine._instance.gameObject.transform.Find(“Effects”);
// Check if the “Effects” transform is found
if (effectsTransform != null)
{
Debug.Log(“Effects transform found: ” + effectsTransform.name);
// Find the “Mesh_FlameWild(Clone)” GameObject under the “Effects” transform
Transform flameWildTransform = effectsTransform.Find(“Mesh_FlameWild(Clone)”);
// Check if the “Mesh_FlameWild(Clone)” GameObject is found
if (flameWildTransform != null)
{
Debug.Log(“Mesh_FlameWild(Clone) GameObject found under Effects transform”);
// Now you can access the VisualEffect component attached to the GameObject
VisualEffect visualEffect = flameWildTransform.GetComponent<VisualEffect>();
if (visualEffect != null)
{
visualEffect.GetFloat(“FlameParticleSize”);
// VisualEffect component found, you can now use it
// For example, you can modify its parameters
/visualEffect.SetFloat(“FlameParticleSize”, 0.1f);
Debug.Log(“FlameParticleSize is” + visualEffect.GetFloat(“FlameParticleSize”));
}
else
{
Debug.LogWarning(“VisualEffect component not found on GameObject: Mesh_FlameWild(Clone)”);
}
}
else
{
Debug.LogWarning(“GameObject not found under Effects transform: Mesh_FlameWild(Clone)”);
}
}
else
{
Debug.LogWarning(“Effects transform not found under MagioEngine._instance.gameObject”);
}
}

1 Answers
Thomas Staff answered 1 month ago

Hello,
 
Thank you for the question! Actually MagioObjectEffect controls all of VFXGraph variables under the hood so you need to change it there. MagioObjectEffect has an function called public bool SetVFXPropertyValue(VFXProps prop) (line 985 of MagioObjectEffect) which can be used to change the value. There is an example how to use it in class called SetWorldPosElectricSplash.

I hope this will help you!

All the best,
Thomas

Your Answer