本文中的项目来源于 https://github.com/Siccity/xNode
2 简单的使用介绍
我一时之间也没想到用这个xNode做什么好,就来看一下官方的演示案例MathGraph
2.1 预先准备
首先我们再Assets文件夹创建一个文件夹MathGraph,并在该文件夹中创建三个文件夹:Editor、Node和Graph(当然你也可以不这么做,我这么做是为了之后方便我进行管理)
2.2 创建Graph
我们在Graph文件夹下右键Create——xNode——NodeGraph C# Script创建Graph脚本,并设置菜单,如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using XNode;
[Serializable, CreateAssetMenu(fileName = "MathGraph", menuName = "xNode New/Math Graph")]
public class ItemGraph : NodeGraph
{
}
然后我们就可以通过右键Create——xNode New——Item Graph创建界面了,我们通过双击Scriptable Object来打开编辑界面
2.3 创建Node
类似,我们在Node文件夹下右键Create——xNode——Node C# Script创建Graph脚本,并设置菜单,如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XNode;
[System.Serializable]
public class Vector : Node
{
[Input] public float x, y, z;
[Output] public Vector3 vector;
public override object GetValue