Skip to content

Root Nodes and About Them

CoffeeVampir3 edited this page Apr 11, 2021 · 5 revisions

public interface IRootNode

All graphs need a root node, it's not optional. To create one, you need a Runtime Node and you need that Runtime Node to use the Root Node interface. You should probably only have one root node per graph. No, really.

Ensure that you actually register your root node to your graph controller, like so

    [RegisterTo(typeof(DialogueGraphBlueprint))]
    public class DialogueRoot : RuntimeNode, IRootNode
    {
        [Out]
        public ValuePort<Any> rootPort = new ValuePort<Any>();

        protected override RuntimeNode OnEvaluate(https://github.com/CoffeeVampir3/Graphify/wiki/Blackboard-API)
        {
            if (!rootPort.IsLinked()) return this;
            return rootPort.FirstNode();
        }
    }

Just about the most generic root node imaginable. Technically, you can give your root node a searchable path and create multiple instances. That's not a good idea. Just let the root node be the root node, yeah?