nGUI and Behavior Designer

Does anyone have experience getting nGUI and Behavior Designer to work together? In specific, how would I send button click data to Behavior Designer?

Because the tasks are not derived from MonoBehaviour it isn’t completely straight forward, but it doesn’t involve too much work either.

The easiest way would be to create a new MonoBehavior script that receives the NGUI click events. That script would then call the task that you want to receive the click data. In order to reference that task from the MonoBehaviour script you will need to create a variable of that task type. You could also do this using events but this is the most straight forward.

Here’s the task:

using UnityEngine;
using BehaviorDesigner.Runtime.Tasks;

public class MyTask : Action
{
	public override void OnAwake()
	{
		gameObject.GetComponent<GUIClickEventReceiver>().myTask = this;
	}

	public void SendData(object data)
	{
		...
	}
}

GUIClickEventReceiver would then look something like:

using UnityEngine;
public class GUIClickEventReceiver : MonoBehaviour {
	
	public MyTask myTask;
	
	public void OnClick()
	{
		myTask.SendData(data);
	}
}

Thanks; that looks pretty simple and sensible.