PlayMaker Help & Tips > PlayMaker Help

Write C#

(1/1)

kaelcabral:
Hey All.
How can I write this on the C#?

Breadman:
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

jeanfabre:
Hi,

Ok, here it is:


--- Code: ---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");
}
}
}
}

--- End code ---


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

kaelcabral:
Thanks Guys!

Really appreciated!! ;)

Navigation

[0] Message Index

Go to full version