playMaker

Author Topic: Send playmaker variables to another script  (Read 2619 times)

TommyA

  • Playmaker Newbie
  • *
  • Posts: 26
Send playmaker variables to another script
« 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?





jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send playmaker variables to another script
« Reply #1 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