Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Rajeev on March 20, 2021, 09:13:07 AM
-
Hello,
I need to change the values of several variables in a Playmaker FSM. I am now doing it with this script:
using UnityEngine;
using HutongGames.PlayMaker;
public class ChannelNameValues : MonoBehaviour
{
public PlayMakerFSM fsm;
public void ResetChannelName()
{
fsm.FsmVariables.GetFsmString("Step 1 Name").Value = "";
fsm.FsmVariables.GetFsmString("Step 2 Name").Value = "";
fsm.FsmVariables.GetFsmString("Step 3 Name").Value = "";
.
.
.
.
}
}
I need to change the values of about 40 variables in one FSM and I know that this is not the correct way to do it.
Could you please help with an easier method of changing the values ... something similar to how all the buttons can be set active or inactive by putting them in a list and using "foreach (GameObject obj in objects)
{
obj.GetComponent<Button>().interactable = false;
}
"
Thanking you in advance,
Rajeev
-
Hi.
I updated your post and wrapped the code so its easier to read.
Maybe you could use a string :
int stepCount = 30;
for (int i = 0; i < stepCount; i++)
{
string stepName = "Step " + i + " Name";
fsm.FsmVariables.GetFsmString(stepName).Value = "";
}
-
Hello Sir,
Your code worked perfectly for me. Thank you very much sir. It saved me a heap big amount of work. Sorry for the delay in replying.
Regards,
Rajeev
-
Hi.
No problem