Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: kaelcabral on November 28, 2013, 05:37:01 PM
-
Hey All.
How can I write this on the C#?
-
Hi,
I don't know much about scripting at all (which is why I use PlayMaker). I have a feeling you will probably meet a lot of people like me on this forum, who would want to help you but don't know scripting! :(
I was able to find this, hopefully it helps! Supposedly converts UnityScript to C#
http://www.m2h.nl/files/js_to_c.php
-
Hi,
Ok, here it is:
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;
public class Button : MonoBehaviour {
PlayMakerFSM RandNumFSM;
// Use this for initialization
void Start () {
GameObject _go = GameObject.Find("GUIText_RandNum");
if (_go!=null)
{
RandNumFSM = _go.GetComponent<PlayMakerFSM>();
}
if (RandNumFSM==null)
{
Debug.LogError("GUIText_RandNum PlayMaker Fsm not found");
}
}
void OnGUI () {
if (GUI.Button(new Rect(295,145,75,40),"Rand"))
{
if (RandNumFSM!=null)
{
RandNumFSM.Fsm.Event("set_number");
}
}
}
}
However, I strongly recommand you don't use the Find method, and instead make RandNumFSM a public variable and in the Unity inspector, drag the fsm you want to target.
Bye,
Jean
-
Thanks Guys!
Really appreciated!! ;)