xNode

其他资源 2025-08-03

下载 /资产商店 /文档

支持KO-FI或Patreon上的xNode

要获得全面的ODIN支持,请考虑使用Kajed82的叉子

xNode

想开发基于节点的插件吗?那是给你的。您可以将其作为存档下载并拆开新的Unity项目,也可以将其连接为GIT子模块。

xNode是超级用户友好,直观的,并且将立即帮助您获得节点图的好处。它的占地面积最小,它是定制状态机器,对话系统,决策者等的理想基础。

关键功能

  • 运行时轻量级
  • 几乎没有样板代码
  • 强大的编辑器和运行时代码
  • 没有运行时反射(除非您需要在运行时编辑/构建节点图。在这种情况下,所有反射都被缓存。)
  • 不依赖任何第三方插件
  • 自定义节点检查器代码与常规自定义检查器代码非常相似
  • 由Unity 5.3及以上支持

Wiki

  • 入门 - 创建您的第一个节点节点和图形
  • 示例分支机构 - 查看其他小型项目

安装

指示

使用Unity软件包管理器安装

通过git URL (需要Unity版本2018.3.0b7或更高版本)

要使用Unity软件包管理器将该项目作为GIT依赖性安装,请将以下行添加到您的项目的清单中。

"com.github.siccity. xNode ": "https://*githu**b.com/siccity/xNode.git"

您将需要在系统的路径中安装git并提供。

如果您在项目中使用汇编定义,则需要添加xNode和/或xNode编辑器作为汇编定义引用。

通过OpenUpm

该软件包可在OpenUPM注册表中找到。建议通过OpenUPM-CLI安装它。

openupm add com.github.siccity. xNode

使用git安装

通过git子模块

要在您现有的GIT项目中添加xNode作为子模块,请从您的项目root中运行以下GIT命令:

xNode ">
git submodule add git@github.com:Siccity/ xNode .git Assets/Submodules/ xNode

安装“旧方式”

如果您没有源控制或软件包管理器可用,则可以简单地将源文件复制到资产文件夹中。

节点示例:

("b", this.b); // After you've gotten your input values, you can perform your calculations and return a value if (port.fieldName == "result") switch(mathType) { case MathType.Add: default: return a + b; case MathType.Subtract: return a - b; case MathType.Multiply: return a * b; case MathType.Divide: return a / b; } else if (port.fieldName == "sum") return a + b; else return 0f; } }">
 // public classes deriving from Node are registered as nodes for use within a graph
public class MathNode : Node {
    // Adding [Input] or [Output] is all you need to do to register a field as a valid port on your node 
    [ Input ] public float a ;
    [ Input ] public float b ;
    // The value of an output node field is not used for anything, but could be used for caching output results
    [ Output ] public float result ;
    [ Output ] public float sum ;

    // The value of 'mathType' will be displayed on the node in an editable format, similar to the inspector
    public MathType mathType = MathType . Add ;
    public enum MathType { Add , Subtract , Multiply , Divide }
    
    // GetValue should be overridden to return a value for any specified output port
    public override object GetValue ( NodePort port ) {

        // Get new a and b values from input connections. Fallback to field values if input is not connected
        float a = GetInputValue < float > ( "a" , this . a ) ;
        float b = GetInputValue < float > ( "b" , this . b ) ;

        // After you've gotten your input values, you can perform your calculations and return a value
        if ( port . fieldName == "result" )
            switch ( mathType ) {
                case MathType . Add : default : return a + b ;
                case MathType . Subtract : return a - b ;
                case MathType . Multiply : return a * b ;
                case MathType . Divide : return a / b ;
            }
        else if ( port . fieldName == "sum" ) return a + b ;
        else return 0f ;
    }
}

插件

插件是将功能添加到xNode存储库

  • xNode组:添加可解析的组

社区

加入Discord服务器以留下反馈或获得支持。请随时在“问题”页面中留下建议/请求。

下载源码

通过命令行克隆项目:

git clone https://github.com/Siccity/xNode.git