private void CreateNodes() { foreach (Node node in repository.DeserializeNodes()) { graphView.AddNodeView(node.editorPos, node); } var nodes = Nodes; foreach (var n in nodes) { n.Deserialize(nodes, graphView); } foreach (DataExNode dataExNode in repository.DeserializeDataExNodes()) { if (dataExNode is GroupDataExNode groupData) { graphView.AddGroup(groupData.GroupName, groupData.GroupPosition).Deserialize(groupData, nodes); } } }
private static void GenerateRequirements(BehaviourTree behaviourTree, StringBuilder builder) { HashSet <Type> types = new HashSet <Type>(); foreach (var node in behaviourTree.DeserializeNodes()) { types.Add(node.GetType()); } HashSet <Type> requiredTypes = new HashSet <Type>(); foreach (var t in types) { var atts = t.GetCustomAttributes(true); foreach (var a in atts) { if (a is RequireComponent requireComponent) { if (requireComponent.m_Type0 != null) { requiredTypes.Add(requireComponent.m_Type0); } if (requireComponent.m_Type1 != null) { requiredTypes.Add(requireComponent.m_Type1); } if (requireComponent.m_Type2 != null) { requiredTypes.Add(requireComponent.m_Type2); } } } } foreach (var requiredType in requiredTypes) { builder.AppendLine("[RequireComponent(typeof(" + requiredType.ToString() + "))]"); } }