Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: colpolstudios on January 11, 2014, 03:00:43 PM
-
Hi after searching I found this reference.
#pragma strict
import HutongGames.PlayMaker;
function Start () {
// get the global variable pointer
var _globalstring:FsmString = FsmVariables.GlobalVariables.FindFsmString("Frame compairing");
// output its value
//Debug.Log(_globalstring.Value);
/* set a new value
_globalstring.Value = "new value";
// coutput the new value. Also check in the Global variable browser, the new value will be displaed there too.
Debug.Log(_globalstring.Value);*/
}
I had to comment out all of the areas as unity kept on saying there was issues.
I need to do this,
function TotalFramesUsed(FramesUsed : float){
FrameNumber = FramesUsed;
_globalstring.Value = "FramesUsed";
}
As you can tell i am not a coder but trying hard to learn.
If i could set the value of the _globalstring.Value i could then use playmaker to compair this value and do something.
Help please
-
However this c# script is able to show the changed value:
using HutongGames.PlayMaker;
using UnityEngine;
public class AccessGlobals : MonoBehaviour
{
public int anim_frames;
private FsmInt FrameNumber;
void Start ()
{
// Get the global fsm variables
var globalVariables = FsmVariables.GlobalVariables;
// Get the global numLives variable
FrameNumber = globalVariables.GetFsmInt("Frame compairing");
// Set the global variable to inspector value
FrameNumber.Value = anim_frames;
}
void Update ()
{
// get the current global variable value to show in inspector
anim_frames = FrameNumber.Value;
}
}
How do I do this using java script??
-
Hi,
not trying to avoid the question, but why not using c# then?
I never use javascript, but if you don't find the source of the problem,I'll have a look.
bye,
Jean
-
To be honest this has been solved for this specific request.
But i would still like to know the correct way to access play maker global variables using unity java script.
Please.
-
Hi,
This is the way:
#pragma strict
import HutongGames.PlayMaker;
function Start () {
var _globalstring : FsmString = FsmVariables.GlobalVariables.FindFsmString("global string");
Debug.Log(_globalstring.Value);
_globalstring.Value += ", How are you?";
Debug.Log(_globalstring.Value);
}
Of maybe I misunderstand what you are trying to achieve?
Bye,
Jean
-
Thanks Jean, but can I get back to this at a later date?
I am busy at present but will come back
-
Hi,
In your own time of course.
bye,
Jean