public static GetSharpEvent AddCSharpGetNode(this FlowGraph graph, EventInfo info, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <GetSharpEvent>(pos); node.SetEvent(info); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static MacroNodeWrapper AddMacroNode(this FlowGraph graph, Macro m, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <MacroNodeWrapper>(pos); node.macro = (Macro)m; Finalize(node, sourcePort, dropInstance); return(node); }
///---------------------------------------------------------------------------------------------- //... public static CustomObjectWrapper AddObjectWrapper(this FlowGraph graph, System.Type type, Vector2 pos, Port sourcePort, UnityEngine.Object dropInstance) { var node = (CustomObjectWrapper)graph.AddNode(type, pos); node.SetTarget(dropInstance); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static FlowNode AddReflectedExtractorNode(this FlowGraph graph, System.Type type, Vector2 pos, Port sourcePort, object dropInstance) { var genericType = typeof(ReflectedExtractorNodeWrapper <>).MakeGenericType(type); var node = (FlowNode)graph.AddNode(genericType, pos); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static ReflectedFieldNodeWrapper AddFieldSetNode(this FlowGraph graph, FieldInfo f, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <ReflectedFieldNodeWrapper>(pos); node.SetField(f, ReflectedFieldNodeWrapper.AccessMode.SetField); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static UnityEventAutoCallbackEvent AddUnityEventAutoCallbackNode(this FlowGraph graph, FieldInfo field, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <UnityEventAutoCallbackEvent>(pos); node.SetEvent(field, dropInstance); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static ReflectedMethodNodeWrapper AddMethodNode(this FlowGraph graph, MethodInfo m, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <ReflectedMethodNodeWrapper>(pos); node.SetMethodBase(m); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static FlowNode AddVariableSet(this FlowGraph graph, System.Type varType, string varName, Vector2 pos, Port sourcePort, object dropInstance) { var genericType = typeof(SetVariable <>).MakeGenericType(varType); var node = (FlowNode)graph.AddNode(genericType, pos); genericType.GetMethod("SetTargetVariableName").Invoke(node, new object[] { varName }); Finalize(node, sourcePort, dropInstance); return(node); }
//... public static ReflectedConstructorNodeWrapper AddContructorNode(this FlowGraph graph, ConstructorInfo c, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <ReflectedConstructorNodeWrapper>(pos); node.SetMethodBase(c); FinalizeConnection(sourcePort, node); DropInstance(node, dropInstance); Select(node); return(node); }
//... public static FlowNode AddSimplexExtractorNode(this FlowGraph graph, System.Type type, Vector2 pos, Port sourcePort, object dropInstance) { var simplexWrapper = typeof(SimplexNodeWrapper <>).MakeGenericType(type); var node = (FlowNode)graph.AddNode(simplexWrapper, pos); FinalizeConnection(sourcePort, node); DropInstance(node, dropInstance); Select(node); return(node); }
//... public static CSharpAutoCallbackEvent AddCSharpEventAutoCallbackNode(this FlowGraph graph, EventInfo info, Vector2 pos, Port sourcePort, object dropInstance) { var node = graph.AddNode <CSharpAutoCallbackEvent>(pos); node.SetEvent(info, dropInstance); FinalizeConnection(sourcePort, node); DropInstance(node, dropInstance); Select(node); return(node); }
//... public static FlowNode AddFlowNode(this FlowGraph graph, System.Type type, Vector2 pos, Port sourcePort, object dropInstance) { if (type.IsGenericTypeDefinition) { type = type.MakeGenericType(type.GetFirstGenericParameterConstraintType()); } var node = (FlowNode)graph.AddNode(type, pos); Finalize(node, sourcePort, dropInstance); return(node); }
///Macro Nodes public static UnityEditor.GenericMenu AppendMacroNodesMenu(this FlowGraph graph, UnityEditor.GenericMenu menu, string baseCategory, Vector2 pos, Port sourcePort, object dropInstance) { var projectMacroGUIDS = UnityEditor.AssetDatabase.FindAssets("t:Macro"); foreach (var guid in projectMacroGUIDS) { var path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid); var macro = (Macro)UnityEditor.AssetDatabase.LoadAssetAtPath(path, typeof(Macro)); if (sourcePort is ValueOutput || sourcePort is FlowOutput) { if (!macro.inputDefinitions.Select(d => d.type).Any(d => d.IsAssignableFrom(sourcePort.type))) { continue; } } if (sourcePort is ValueInput || sourcePort is FlowInput) { if (!macro.outputDefinitions.Select(d => d.type).Any(d => sourcePort.type.IsAssignableFrom(d))) { continue; } } var category = baseCategory + (!string.IsNullOrEmpty(macro.category) ? "/" + macro.category : ""); var name = category + "/" + macro.name; var content = new GUIContent(name, null, macro.comments); if (macro != graph) { menu.AddItem(content, false, () => { graph.AddMacroNode(macro, pos, sourcePort, dropInstance); }); } else { menu.AddDisabledItem(content); } } if (sourcePort == null) { menu.AddItem(new GUIContent("MACROS/Create New...", null, "Create a new macro"), false, () => { var newMacro = EditorUtils.CreateAsset <Macro>(); if (newMacro != null) { var wrapper = graph.AddNode <MacroNodeWrapper>(pos); wrapper.macro = newMacro; } }); } return(menu); }
//... public static FlowNode AddSimplexNode(this FlowGraph graph, System.Type type, Vector2 pos, Port sourcePort, object dropInstance) { if (type.IsGenericTypeDefinition) { type = type.MakeGenericType(type.GetFirstGenericParameterConstraintType()); } var genericType = typeof(SimplexNodeWrapper <>).MakeGenericType(type); var node = (FlowNode)graph.AddNode(genericType, pos); FinalizeConnection(sourcePort, node); DropInstance(node, dropInstance); Select(node); return(node); }
//... public static VariableNode AddVariableGet(this FlowGraph graph, System.Type varType, string varName, Vector2 pos, Port sourcePort, object dropInstance) { var genericType = typeof(GetVariable <>).MakeGenericType(new System.Type[] { varType }); var node = (VariableNode)graph.AddNode(genericType, pos); genericType.GetMethod("SetTargetVariableName").Invoke(node, new object[] { varName }); FinalizeConnection(sourcePort, node); DropInstance(node, dropInstance); Select(node); if (dropInstance != null) { node.SetVariable(dropInstance); } return(node); }