Is there a way to expose to Inspector and trigger UnityEvent from a Script Graph (Visual Scripting)?
It is pretty trivial from code
but I didn’t find any block/node/variable to do it in VS.
I want to create a simple script graph where OnTriggerEnter triggers (invokes) a UnityEvent and different types of actions can be assigned via Inspector.
I’m trying to learn Visual Scripting after spending 7+ years in classic C# in order to be able to help my students.
Here’s my C# code that I want to implement in Visual Scripting
using UnityEngine;
using UnityEngine.Events;
[RequireComponent(typeof(Collider))]
public class EnterExitTrigger : MonoBehaviour
{
[SerializeField] private UnityEvent triggerEnter;
[SerializeField] private UnityEvent triggerExit;
private void Awake()
{
Collider attachedCollider = GetComponent<Collider>();
if (attachedCollider != null)
{
attachedCollider.isTrigger = true;
}
else
{
Debug.LogError("EnterExitTrigger script cannot find any Collider component on gameObject.name = " + gameObject.name);
}
}
private void OnTriggerEnter(Collider other)
{
triggerEnter.Invoke();
}
private void OnTriggerExit(Collider other)
{
triggerExit.Invoke();
}
}