private void HookUpOutput(GraphOutput graphOutput) { LogicNode node = _outputNodes.Find(n => n.NodeGuid == graphOutput.NodeGuid); var events = node.GetType().GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (EventInfo eventInfo in events) { var attrs = eventInfo.GetCustomAttributes(typeof(OutputAttribute), false) as OutputAttribute[]; if (attrs.Length > 0) { if (eventInfo.Name == graphOutput.MemberName) { Type[] types = eventInfo.EventHandlerType.GetGenericArguments(); graphOutput.OutputType = types[0]; graphOutput.SubscribeRaiseUpdate(eventInfo, node); } if (attrs.Length > 1) { Debug.LogWarning(eventInfo.Name + " on " + node + "has multiple input attributes."); } } } }
private void LoadOutputs(List <GraphOutput> outputs) { foreach (var node in _outputNodes) { var events = node.GetType().GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (EventInfo eventInfo in events) { var attrs = eventInfo.GetCustomAttributes(typeof(OutputAttribute), false) as OutputAttribute[]; if (attrs.Length > 0) { Debug.Log($"Output attribute found{attrs[0]}"); Type[] types = eventInfo.EventHandlerType.GetGenericArguments(); if (types.Length > 1) { Debug.LogError( eventInfo + " has more than one generic type, only one currently supported."); } else if (types.Length == 0) { Debug.LogError(eventInfo + " has more than no generic types."); } GraphOutput graphOutput = new GraphOutput(); graphOutput.MemberName = eventInfo.Name; graphOutput.NodeGuid = node.NodeGuid; graphOutput.DisplayName = node.DisplayName + " " + eventInfo.Name; graphOutput.OutputType = types[0]; outputs.Add(graphOutput); if (attrs.Length > 1) { Debug.LogWarning(eventInfo.Name + " on " + node + "has multiple input attributes."); } } } } }