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