Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: kaelcabral on November 28, 2013, 03:37:01 PM

Title: Write C#
Post by: kaelcabral on November 28, 2013, 03:37:01 PM
Hey All.
How can I write this on the C#?
Title: Re: Write C#
Post by: Breadman on November 30, 2013, 12:01:39 AM
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
Title: Re: Write C#
Post by: jeanfabre on November 30, 2013, 11:57:26 AM
Hi,

Ok, here it is:

Code: [Select]
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

Title: Re: Write C#
Post by: kaelcabral on November 30, 2013, 03:43:30 PM
Thanks Guys!

Really appreciated!! ;)