Hi there,
I’m new to the Visual Scripting system. One of the first things I’m trying to do is creating some custom units to drive some high level behaviour. I’d like to access the game object that owns the State Machine component that is currently running inside my Unit… is there an elegant way to do this?
here’s a code snippet…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.VisualScripting;
public class DebugLogNode : Unit
{
[DoNotSerialize]
public ControlInput InputTrigger;
[DoNotSerialize]
public ControlOutput OutputTrigger;
[DoNotSerialize]
public ValueInput Message;
protected override void Definition()
{
InputTrigger = ControlInput("InputTrigger", Execute);
OutputTrigger = ControlOutput("OutputTrigger");
Message = ValueInput<string>("Message", "Hello ");
}
private ControlOutput Execute(Flow flow)
{
Debug.Log("[Log] " + flow.GetValue<string>(Message));
// TODO get my game object that this state machine is running
//GameObject gameObject = ???
return OutputTrigger;
}
}
Thanks in advance,
George