Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: CreativeVulpine on August 05, 2019, 03:36:32 PM
-
Hi, I am relatively new to Playmaker.
I am trying to work on a save and load system for my game in C#, however I am stuck on how to call a global variable I created in PlayMaker for my in game clock.
The variable is called rawTime and is a float, I want my C# Save manager to access it and save it as a string to a file.
I've followed many tutorials and the PlayMaker documents, but I still cannot wrap my head around it.
Does anyone have an example of how to do this in C#?
Thank you,
CreativeVulpine :)
-
Welcome,
Here's what I found:
https://hutonggames.com/playmakerforum/index.php?topic=2348.msg10370#msg10370
If you follow the links there, Jean posted this:
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)
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
Maybe that works. Otherwise, you could set the global variable from PlayMaker, i.e. PlayMaker writes the variable into your save script. To do this, you need to write a (relative simple) custom action. See here. (https://hutonggames.com/playmakerforum/index.php?topic=13389.0)