public EventManager(SymboleManager symboleManager, FlowchartEditorWindow few, Action <Vector2> OnPan) { this.symboleManager = symboleManager; this.few = few; this.OnPan = OnPan; SetupSymboleMenu(); }
public override void OnGUI() { var variableEnum = SymboleManager.GetVariableEnum(); var stringValue = Name; int index = 0; if (variableEnum.Contains(stringValue)) { index = variableEnum.IndexOf(stringValue); } var tmp = Name; EditorGUILayout.BeginHorizontal(); GUILayout.Space(13); if (variableEnum != null && variableEnum.Count > 0) { Name = variableEnum[EditorGUILayout.Popup("Name", index, variableEnum.ToArray(), GUILayout.Width(NodeSize.width - 13))]; } else { EditorGUILayout.LabelField("Name", "No Variables", GUILayout.Width(NodeSize.width - 13)); } EditorGUILayout.EndHorizontal(); if (Variable == null) { Variable = SymboleManager.GetVariable(Name); } if (Name == tmp) { Variable = SymboleManager.GetVariable(Name); } base.OnGUI(); }
public override object GetValue(ConnectionPoint point) { SymboleManager.DrawSymbole(GetInstanceID()); double a = System.Convert.ToDouble(GetInputValue <object>("A")); double b = System.Convert.ToDouble(GetInputValue <object>("B")); // After you've gotten your input values, you can perform your calculations and return a value if (point.name == "Result") { switch (m_mathType) { case MathType.Divide: if (b != 0) { return(a / b); } return(0); case MathType.Multiply: return(a * b); case MathType.Add: default: return(a + b); case MathType.Subtract: return(a - b); } } else { return(base.GetValue(point)); } }
public override void Function() { if (InputConnected("A")) { switch (m_debugLogType) { case DebugLogType.Log: SymboleManager.DrawSymbole(GetInstanceID()); object a = GetInputValue <object>("A"); Debug.Log(a); break; } } }
public void Load(VCSUGraph graph) { symboleManager = new SymboleManager(this); eventManager = new EventManager(symboleManager, this, OnPan); symboleManager.graph = graph; if (!string.IsNullOrEmpty(graph.XmlData)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(XmlDictionary <string, VariableTest>)); using (StringReader reader = new StringReader(graph.XmlData)) { symboleManager.graph.variables = (XmlDictionary <string, VariableTest>)xmlSerializer.Deserialize(reader); } } }
public override object GetValue(ConnectionPoint point) { SymboleManager.DrawSymbole(GetInstanceID()); string name = GetInputValue <string>("Name"); if (!string.IsNullOrEmpty(name)) { Name = name; } if (point.name == "Value") { //var Variable = SymboleManager.GetVariable(Name); if (Variable != null) { return(Value = Variable.value); } } return(base.GetValue(point)); }
public void InitializeAttributes() { Type type = this.GetType(); if (name == string.Empty) { name = type.Name; } if (type.GetCustomAttribute(typeof(ReceivableAttribute)) != null) { shouldReceive = true; Receive = CreateInstance <ConnectionCallPoint>(); Receive.Init(this, ConnectionType.Receive); Receive.name = name + "Receive"; SymboleManager.AddCallStatic(Receive); } if (type.GetCustomAttribute(typeof(CallableAttribute)) != null) { shouldCall = true; Call = CreateInstance <ConnectionCallPoint>(); Call.Init(this, ConnectionType.Call); Call.name = name + "Receive"; SymboleManager.AddCallStatic(Call); } var fields = type.GetFields(); foreach (var field in fields) { if (field.GetCustomAttribute(typeof(IgnoreAttribute)) != null) { continue; } var attri = field.GetCustomAttribute(typeof(PointAttribute)); if (attri != null) { //var attri = attris[0]; var cp = CreateInstance <ConnectionPoint>(); cp.Init(this, field, (PointAttribute)attri); if (fieldPoints == null) { fieldPoints = new List <ConnectionPoint>(); } if (cp.connectionType == ConnectionType.Output) { NoOutput = false; } fieldPoints.Add(cp); SymboleManager.AddSymboleStatic(cp); } else { if (field.IsPublic && !field.IsStatic && field.Name != "NodeSize" && field.Name != "fieldPoints" && field.Name != "NoOutput" && field.Name != "shouldCall" && field.Name != "shouldReceive") { if (childFields == null) { childFields = new List <Field>(); } if (field.GetCustomAttribute(typeof(VariableEnumAttribute)) != null) { childFields.Add(new Field(field.Name, field, true)); } else if (field.GetCustomAttribute(typeof(EnumLableAttribute)) != null) { childFields.Add(new Field(field.Name, field, isEnumLable: true)); } else { childFields.Add(new Field(field.Name, field, false)); } } } } Init(); }
// Start is called before the first frame update private void OnGUI() { ZoomEvent(); DrawEditor(); Rect graphRect = editorSize; var center = graphRect.center; _zoomAdjustment = GUIScaleUtility.BeginScale(ref graphRect, center, ZoomScale, true, false); if (symboleManager != null) { symboleManager.Draw(); } GUIScaleUtility.EndScale(); GUILayout.BeginHorizontal("Toolbar"); if (GUILayout.Button("New", "ToolbarButton")) { symboleManager = new SymboleManager(this); var graph = symboleManager.graph = CreateInstance <VCSUGraph>(); if (!System.IO.Directory.Exists("Assets/VisualCSharpUnity/Graphs/Temp")) { System.IO.Directory.CreateDirectory("Assets/VisualCSharpUnity/Graphs/Temp"); } AssetDatabase.CreateAsset(symboleManager.graph, "Assets/VisualCSharpUnity/Graphs/Temp/Temp.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); ProjectWindowUtil.ShowCreatedAsset(graph); eventManager = new EventManager(symboleManager, this, OnPan); } if (GUILayout.Button("Save", "ToolbarButton")) { symboleManager.Save(); } if (GUILayout.Button("Load", "ToolbarButton")) { Load(); } if (GUILayout.Button("Close", "ToolbarButton")) { CloseGraph(); } if (symboleManager != null && symboleManager.graph) { symboleManager.ShowThread = GUILayout.Toggle(symboleManager.ShowThread, "ThreadHighLight", "ToolbarButton"); } GUILayout.FlexibleSpace(); if (symboleManager != null && symboleManager.graph) { symboleManager.UpdateTime = EditorGUILayout.Slider("ThreadHighLightSpeed", symboleManager.UpdateTime, 1, 10); GUILayout.Label(symboleManager.graph.name); } GUILayout.EndHorizontal(); if (symboleManager != null) { if (GUI.Button(new Rect(editorSize.width - 99, editorSize.height - 25, 96, 18), "Remove Nodes")) { symboleManager.OnClickRemoveAllNode(); } if (symboleManager.RemovedCP != null && symboleManager.RemovedCP.Count > 0 && symboleManager.RemovedS != null && symboleManager.RemovedS.Count > 0) { if (GUI.Button(new Rect(editorSize.width - 291, editorSize.height - 25, 182, 18), "Restore Last Removed Nodes")) { symboleManager.OnClickRestoreAllNodes(); } } if (GUI.Button(new Rect(editorSize.width - 99, editorSize.height - 60, 96, 18), "Reset")) { panOffset = Vector2.zero; _zoom = Vector2.one; } } if (eventManager != null) { eventManager.ProcessEvent(Event.current); } if (GUI.changed) { Repaint(); } }
public void CloseGraph() { symboleManager.RemoveComplete(); symboleManager = null; eventManager = null; }