What are the conditions for "Unit is never entered"?

I wrote my own script that I will write about later.
The node itself is working as expected, but the connected node is in a state of “Unit is never entered”.
Why is this?

Env

  • Unity2021.1.0b8
  • VisualScripting 1.5.1-pre.3

using System.Collections;
using Unity.VisualScripting;
using UnityEngine;

namespace ApureEasing
{
    [UnitTitle("FloatEasing")]
    [UnitCategory("ApureEasing")]
    public class FloatEasingNode : Unit
    {
        [DoNotSerialize]
        public ControlInput start { get; private set; }

        [DoNotSerialize]
        public ControlOutput tick { get; private set; }

        [DoNotSerialize]
        public ValueOutput value { get; private set; }

        [DoNotSerialize]
        public ControlOutput complete { get; private set; }

        [DoNotSerialize]
        public ValueInput easing { get; private set; }

        [DoNotSerialize]
        public ValueInput duration { get; private set; }

        [DoNotSerialize]
        public ValueInput endValue { get; private set; }

        [DoNotSerialize]
        public ValueInput startValue { get; private set; }

        private float startTime;

        protected override void Definition()
        {
            start = ControlInputCoroutine(nameof(start), RunCoroutine);
            tick = ControlOutput(nameof(tick));
            complete = ControlOutput(nameof(complete));
            easing = ValueInput(nameof(easing), Easing.Linear);
            duration = ValueInput(nameof(duration), 1f);
            startValue = ValueInput(nameof(startValue), 0f);
            endValue = ValueInput(nameof(endValue), 1f);
            value = ValueOutput(nameof(value), GetOutput);
        }

        private IEnumerator RunCoroutine(Flow flow)
        {
            var d = flow.GetValue<float>(duration);
            startTime = Time.time;

            while (startTime + d > Time.time)
            {
                yield return tick;
                yield return null;
            }
            yield return tick;
           flow.Run(complete);
        }

        private float GetOutput(Flow flow)
        {
            var t = flow.GetValue<Easing>(easing);
            var s = flow.GetValue<float>(startValue);
            var e = flow.GetValue<float>(endValue);
            var d = flow.GetValue<float>(duration);

            if (!(startTime + d > Time.time)) return e;
            var v = (Time.time - startTime) / d;
            return Mathf.Lerp(s, e, EasingConvert.Get(t, v));
        }
    }
}
1 Like

Just had same problem. You need to call “Succession(enter, exit)” method
At the end of Definition method just write:
Succession(start, tick);
Succession(start, complete);

4 Likes

Fixed!!! Thank you!!!

Where did you find this out?
I’m trying to do more complex things with my nodes, but advanced usage info seems hard to find (for example, how does flow actually work)

Looks like that API is discussed here: Custom C# nodes | Visual Scripting | 1.7.8

BTW since Unity docs are not keyword oriented, one can use google’s “site:” to find documentation about a keyword, e.g. site:docs.unity3d.com/Packages/com.unity.visualscripting@1.7 succession - Google Search

2 Likes

I’m not good with documentation (plain stuff out of context) so I just learn by jumping from one open github to another, reading code. Also looking for some Youtube tutorials, some of them have links with sources where is also good place to read some code.