Ejemplo n.º 1
0
        /// <summary>
        /// 仅<see cref="SetVariableNode"/>使用
        /// </summary>
        /// <param name="inputVariable"></param>
        /// <returns></returns>
        protected NodeVariable GetInputValueRaw(NodeInputVariable <NodeVariable> inputVariable)
        {
            if (inputVariable == null)
            {
                return(null);
            }

            if (inputVariable.targetNodeId < 0 || inputVariable.targetPortId < 0)
            {
                Debug.LogError("GetInputValueRaw 出错,该端口必须连接到另外一个output端口");
            }

            NodeBase targetNode = null;

            //NodeSequence为null 说明是公共节点
            if (nodeSequence == null)
            {
                targetNode = graphBehaviour.GetCommonNode(inputVariable.targetNodeId);
            }
            else
            {
                targetNode = nodeSequence.GetNodeAlongThisAndParentSequeces(inputVariable.targetNodeId);
            }

            if (targetNode == null)
            {
                return(null);
            }

            NodeVariable nodeVariable = targetNode.GetOutputPortValue(inputVariable.targetPortId);

            return(nodeVariable);
        }
Ejemplo n.º 2
0
        protected T GetInputValue <T>(NodeInputVariable <T> inputVariable)
        {
            if (inputVariable == null)
            {
                return(default(T));
            }

            if (inputVariable.targetNodeId < 0 && inputVariable.targetPortId < 0)
            {
                return(inputVariable.value);
            }

            NodeBase targetNode = null;

            //NodeSequence为null 说明是公共节点
            if (nodeSequence == null)
            {
                targetNode = graphBehaviour.GetCommonNode(inputVariable.targetNodeId);
            }
            else
            {
                targetNode = nodeSequence.GetNodeAlongThisAndParentSequeces(inputVariable.targetNodeId);
            }

            if (targetNode == null)
            {
                return(default(T));
            }

            NodeVariable     nodeVariable   = targetNode.GetOutputPortValue(inputVariable.targetPortId);
            NodeVariable <T> resultVariable = nodeVariable as NodeVariable <T>;

            if (resultVariable == null)
            {
                Debug.LogErrorFormat("获取节点 {0} 的输出端口 {1} 的值发生错误,类型不匹配", inputVariable.targetNodeId, inputVariable.targetPortId);
                return(default(T));
            }

            return(resultVariable.value);
        }