private static ItemSelector.CustomItem GetCustomItem(MultiArithmeticNode source, Type param1, Type param2, Type declaredType, Type returnType, ArithmeticType operatorType) { return(new ItemSelector.CustomItem(string.Format(operatorType.ToString() + " ({0}, {1})", param1.PrettyName(), param2.PrettyName()), () => { uNodeEditorUtility.RegisterUndo(source); source.operatorType = operatorType; while (source.targets.Count > 2) { source.targets.RemoveAt(source.targets.Count - 1); } source.targets[0].CopyFrom(new MemberData(ReflectionUtils.CreateInstance(param1))); source.targets[1].CopyFrom(new MemberData(ReflectionUtils.CreateInstance(param2))); uNodeGUIUtility.GUIChanged(source); }, declaredType.PrettyName() + " : Operator") { icon = uNodeEditorUtility.GetTypeIcon(returnType) }); }
private ItemSelector.CustomItem GetItem(Type type, Type param1, Type param2, Type returnType, MemberData data, ArithmeticType operatorType) { return(new ItemSelector.CustomItem(string.Format(operatorType.ToString() + " ({0}, {1})", param1.PrettyName(), param2.PrettyName()), () => { NodeEditorUtility.AddNewNode(graph.editorData, null, null, mousePositionOnCanvas, (MultiArithmeticNode n) => { if (param1.IsCastableTo(type)) { n.targets[0] = data; n.targets[1] = new MemberData(ReflectionUtils.CreateInstance(param2)); } else { n.targets[0] = new MemberData(ReflectionUtils.CreateInstance(param1)); n.targets[1] = data; } n.operatorType = operatorType; graph.Refresh(); }); }, "Operator") { icon = uNodeEditorUtility.GetTypeIcon(returnType) }); }
public override string GetNodeName() { return(operatorType.ToString()); }