Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: TommyA on August 23, 2012, 02:27:00 AM

Title: Send playmaker variables to another script
Post by: TommyA on August 23, 2012, 02:27:00 AM
Hi
I have two scenes.
One scene is menu and another is game scene.
I made menu scene by Playmaker. (action works fine)
Game scene is made by C# code.
There is global variables in menu scene which made by Playmaker. (character stat value)
I need use this variables in game scene (C# code)
How can I do that?




Title: Re: Send playmaker variables to another script
Post by: jeanfabre on August 29, 2012, 03:00:37 AM
Hi,

 you can access global variables like so:


PlayMakerGlobals.Instance.Variables.GetFsmString("hello")

but be careful, if the variable doesn't exists, it will return the default value of the type ( for a bool it will return false)

Code: [Select]
using UnityEngine;
using System.Collections;
using HutongGames;

public class test : MonoBehaviour {


// Update is called once per frame
void Start () {

Debug.Log(PlayMakerGlobals.Instance.Variables.GetFsmString("hello"));

}
}



bye,

 Jean