// Convert all inlets/outlets into node slots. void PopulateSlots() { // Enumeration flags: all public and non-public members const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; // Inlets (property) foreach (var prop in _runtimeInstance.GetType().GetProperties(flags)) { // Check if it has an inlet attribute. var attrs = prop.GetCustomAttributes(typeof(Wiring.InletAttribute), true); if (attrs.Length == 0) { continue; } // Register the setter method as an input slot. var slot = AddInputSlot("set_" + prop.Name, prop.PropertyType); // Apply the standard nicifying rule. slot.title = GetSlotTitle(prop.Name, false, prop.PropertyType); } // Inlets (method) foreach (var method in _runtimeInstance.GetType().GetMethods(flags)) { // Check if it has an inlet attribute. var attrs = method.GetCustomAttributes(typeof(Wiring.InletAttribute), true); if (attrs.Length == 0) { continue; } // Register the method as an input slot. var args = method.GetParameters(); var dataType = args.Length > 0 ? args[0].ParameterType : null; var slot = AddInputSlot(method.Name, dataType); // Apply the standard nicifying rule. slot.title = GetSlotTitle(method.Name, false, dataType); } // Outlets (UnityEvent members) foreach (var field in _runtimeInstance.GetType().GetFields(flags)) { // Check if it has an outlet attribute. var attrs = field.GetCustomAttributes(typeof(Wiring.OutletAttribute), true); if (attrs.Length == 0) { continue; } // Register it as an output slot. var dataType = ConnectionTools.GetEventDataType(field.FieldType); var slot = AddOutputSlot(field.Name, dataType); // Apply the standard nicifying rule and remove tailing "Event". slot.title = GetSlotTitle(field.Name, true, dataType); } }
// Convert all inlets/outlets into node slots. void PopulateSlots() { // Enumeration flags: all public and non-public members const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; // Inlets (property) foreach (var prop in _runtimeInstance.GetType().GetProperties(flags)) { // Check if it has an inlet attribute. var attrs = prop.GetCustomAttributes(typeof(Wiring.InletAttribute), true); if (attrs.Length == 0) { continue; } var propType = prop.PropertyType; // TE: workaround for not being able to use System.Single as inlets with scripting runtime 4.0 // System.Single is replaced with UnityEngine.WrapMode. Using WrapMode is arbitrary, just something // that doesn't cause an assert deep in the graph system. if (prop.PropertyType == typeof(System.Single)) { propType = typeof(UnityEngine.WrapMode); } // Register the setter method as an input slot. var slot = AddInputSlot("set_" + prop.Name, propType); // Apply the standard nicifying rule. slot.title = ObjectNames.NicifyVariableName(prop.Name); } // Inlets (method) foreach (var method in _runtimeInstance.GetType().GetMethods(flags)) { // Check if it has an inlet attribute. var attrs = method.GetCustomAttributes(typeof(Wiring.InletAttribute), true); if (attrs.Length == 0) { continue; } // Register the method as an input slot. var args = method.GetParameters(); var dataType = args.Length > 0 ? args[0].ParameterType : null; var slot = AddInputSlot(method.Name, dataType); // Apply the standard nicifying rule. slot.title = ObjectNames.NicifyVariableName(method.Name); } // Outlets (UnityEvent members) foreach (var field in _runtimeInstance.GetType().GetFields(flags)) { // Check if it has an outlet attribute. var attrs = field.GetCustomAttributes(typeof(Wiring.OutletAttribute), true); if (attrs.Length == 0) { continue; } // Register it as an output slot. var dataType = ConnectionTools.GetEventDataType(field.FieldType); var slot = AddOutputSlot(field.Name, dataType); // Apply the standard nicifying rule and remove tailing "Event". var title = ObjectNames.NicifyVariableName(field.Name); if (title.EndsWith(" Event")) { title = title.Substring(0, title.Length - 6); } slot.title = title; } }
// Convert all inlets/outlets into Block slots. protected virtual void PopulateSlots() { // Enumeration flags: all public and non-public members const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; var rinst = _runtimeInstance; PropertyInfo actvProp = null; List <PropertyInfo> propList = new List <PropertyInfo> (); propList.Add(null); //allocate first item // Inlets (property) foreach (var prop in rinst.GetType().GetProperties(flags)) { // Check if it has an inlet attribute. var attrs = prop.GetCustomAttributes(typeof(Wiring.InletAttribute), true); if (attrs.Length == 0) { continue; } if (prop.Name == "Active") { actvProp = prop; } else { propList.Add(prop); } } propList [0] = actvProp; foreach (var prop in propList) { if (prop == null) { continue; } // Register the setter method as an input slot. var slot = AddInputSlot("set_" + prop.Name, prop.PropertyType); // Apply the standard nicifying rule. slot.title = ObjectNames.NicifyVariableName(prop.Name); } // InletsArray (property) foreach (var prop in rinst.GetType().GetProperties(flags)) { var attrs = prop.GetCustomAttributes(typeof(Wiring.InletArrayAttribute), true); if (attrs.Length == 0) { continue; } } // Inlets (method) foreach (var method in rinst.GetType().GetMethods(flags)) { // Check if it has an inlet attribute. var attrs = method.GetCustomAttributes(typeof(Wiring.InletAttribute), true); if (attrs.Length == 0) { continue; } // Register the method as an input slot. var args = method.GetParameters(); var dataType = args.Length > 0 ? args[0].ParameterType : null; var a = attrs[0] as Wiring.InletAttribute; for (int i = 0; i < a.count; ++i) { var slot = AddInputSlot(method.Name, dataType); // Apply the standard nicifying rule. slot.title = ObjectNames.NicifyVariableName(method.Name + (a.count > 1?i.ToString():"")); } } // Outlets (UnityEvent members) foreach (var field in rinst.GetType().GetFields(flags)) { // Check if it has an outlet attribute. var attrs = field.GetCustomAttributes(typeof(Wiring.OutletAttribute), true); if (attrs.Length == 0) { continue; } // Register it as an output slot. var dataType = ConnectionTools.GetEventDataType(field.FieldType); var slot = AddOutputSlot(field.Name, dataType); // Apply the standard nicifying rule and remove tailing "Event". var title = ObjectNames.NicifyVariableName(field.Name); if (title.EndsWith(" Event")) { title = title.Substring(0, title.Length - 6); } slot.title = title; } }