i realize that using IMGUI is not really the best way to use buttons however to make this work i am not sure why i don't need to use the GetComponent
i have been altering my script however the following script does not work...
i just wonder if you have any thoughts about why this breaks the button?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandNumButton : MonoBehaviour
{
public PlayMakerFSM RandNumFSM;
void Start()
{
if(RandNumFSM = null)
{
Debug.Log("RandNumFSM was null!");
RandNumFSM = GameObject.Find("GUITEXT_RandNum").GetComponent<PlayMakerFSM>();
}
}
public void OnGUI()
{
// Make a background box
GUI.Box(new Rect(10, 10, 400, 90), "Tutorial 12 - Connecting Scripts to Playmaker Menu");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button(new Rect(20, 40, 80, 20), "Click Me"))
{
Debug.Log("Hello Rene!");
}
// Make the second button.
if (GUI.Button(new Rect(20, 70, 200, 20), "Random Number Generator"))
{
NewMethod();
}
// if (GUILayout.Button("Press Me"))
// Debug.Log("Hello!");
// if (GUILayout.Button("Random Number Generator"))
//{
// RandNumFSM.Fsm.Event("set_number");
//}
}
private void NewMethod()
{
if (RandNumFSM = null)
{
Debug.Log("RandNumFSM was null!");
RandNumFSM.Fsm.Event("set_number");
}
}
}