Exemple #1
0
    public static void Init()
    {
        FlowchartEditorWindow few = GetWindow <FlowchartEditorWindow>();

        few.titleContent = new GUIContent("VisualCS Unity");
        few.Show();
    }
Exemple #2
0
 public EventManager(SymboleManager symboleManager, FlowchartEditorWindow few, Action <Vector2> OnPan)
 {
     this.symboleManager = symboleManager;
     this.few            = few;
     this.OnPan          = OnPan;
     SetupSymboleMenu();
 }
Exemple #3
0
 public static void Init(VCSUGraph graph)
 {
     if (graph)
     {
         FlowchartEditorWindow few = GetWindow <FlowchartEditorWindow>();
         few.titleContent = new GUIContent("VisualCS Unity");
         few.Load(graph);
         few.Show();
     }
 }
 public SymboleManager(FlowchartEditorWindow _few)
 {
     few = _few;
     background.alignment        = TextAnchor.UpperCenter;
     background.fontStyle        = FontStyle.Bold;
     background.normal.textColor = Color.white;
     actionAddPoint     = AddPoint;
     actionAddCallPoint = AddCallPoint;
     SSR          = SetStaticReferance;
     setselection = SetSelection;
 }
 public void Draw()
 {
     if (points != null)
     {
         foreach (var point in points)
         {
             if (point.connectionType == ConnectionType.Output)
             {
                 foreach (var input in point.Connections)
                 {
                     if (input.connectionType == ConnectionType.Input)
                     {
                         //var col = Color.Lerp(point.knobeColor, input.knobeColor, 0.5f);
                         DrawConnectionBezier(FlowchartEditorWindow.GraphToScreenSpace(point.PointPos.center), FlowchartEditorWindow.GraphToScreenSpace(input.PointPos.center), point.knobeColor, input.knobeColor);
                     }
                 }
             }
         }
     }
     if (callPoints != null)
     {
         foreach (var point in callPoints)
         {
             if (point.connectionType == ConnectionType.Call)
             {
                 foreach (var receive in point.connections)
                 {
                     if (receive.connectionType == ConnectionType.Receive)
                     {
                         //var col = Color.Lerp(point.knobeColor, input.knobeColor, 0.5f);
                         DrawBezier(point.Point.center, receive.Point.center, point.knobeColor);
                     }
                 }
             }
         }
     }
     if (symboles != null)
     {
         DrawSymboles();
         GUI.changed = true;
     }
     if (selectedOutputCallPoint)
     {
         DrawBezierPreview(few.InvGraphToScreenSpace(selectedOutputCallPoint.Point.center));
         GUI.changed = true;
     }
     if (selectedOutputPoint)
     {
         DrawBezierPreview(selectedOutputPoint.PointPos.center);
         GUI.changed = true;
     }
 }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        GUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);
        if (GUILayout.Button("Open Graph"))
        {
            FlowchartEditorWindow.Init(graph);
        }
        EditorGUILayout.PropertyField(serializedObject.FindProperty("symboles"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("connectionPoints"), true);
        GUILayout.EndVertical();
        XmlDictionary <string, VariableTest> renameds = new XmlDictionary <string, VariableTest>();

        foreach (var variable in variables)
        {
            var frect    = EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
            var fboxRect = new Rect(frect.x, frect.y - 1.5f, frect.width + 1, frect.height + 2.5f);
            GUI.Box(fboxRect, "");
            GUI.Button(new Rect(frect.x + 5, frect.center.y - 7.5f, 20, 20), '\u003D'.ToString(), GUIStyle.none);
            var name = variable.Value.name;
            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            variable.Value.name = EditorGUILayout.TextField(variable.Value.name);
            GUILayout.EndHorizontal();
            var variableType = variable.Value.variableType;
            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            variable.Value.variableType = (VariableType)EditorGUILayout.EnumPopup(variable.Value.variableType);
            GUILayout.EndHorizontal();
            if (variableType != variable.Value.variableType)
            {
                GUIChanged = true;
            }
            Tuple <bool, object> value = null;
            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            if (variable.Value.variableType != VariableType.Object)
            {
                value = GUIExtended.DrawGUISwitch(variable.Value.variableType.ToString(), variable.Value.value);
            }
            else
            {
                value = GUIExtended.DrawGUIUObject(variable.Value.value);
            }
            GUILayout.EndHorizontal();
            if (value != null)
            {
                if (value.Item1 == true)
                {
                    GUIChanged = true;
                }
                variable.Value.value = value.Item2;
            }
            if (name != variable.Value.name)
            {
                renameds.Add(variable.Key, variable.Value);
            }
            EditorGUILayout.EndVertical();
        }
        foreach (var renamed in renameds)
        {
            var index = variables.Values.IndexOf(renamed.Value);
            variables.RemoveAt(index);
            if (variables.Count < index)
            {
                variables.Add(renamed.Key, renamed.Value);
            }
            else
            {
                variables.Insert(index, new XmlKeyValuePair <string, VariableTest>(renamed.Key, renamed.Value));
            }
        }
        var trect    = EditorGUILayout.BeginHorizontal(EditorStyles.inspectorFullWidthMargins);
        var rect     = GUILayoutUtility.GetRect(trect.width, trect.height + 16);
        var tboxRect = new Rect(trect.x, rect.y, trect.width - 30, rect.height);

        TempVariable = EditorGUI.TextField(tboxRect, TempVariable);
        if (GUI.Button(new Rect(trect.width - 30, rect.y, 30, rect.height), '\u002B'.ToString()) && !string.IsNullOrEmpty(TempVariable))
        {
            var variable = new VariableTest();
            variable.name = TempVariable;
            variables.Add(TempVariable, variable);
            TempVariable = string.Empty;
            GUIChanged   = true;
        }
        if (string.IsNullOrEmpty(TempVariable))
        {
            EditorGUI.LabelField(tboxRect, "(New Variable Name)", TempLable());
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("REMOVE"))
        {
            if (variables.Count > 0)
            {
                variables.RemoveAt(variables.IndexOf(variables.Last()));
                GUIChanged = true;
            }
        }
        GUILayout.EndHorizontal();
        if (variables != null && variables.Count > 0)
        {
            SerializeData();
        }
        serializedObject.ApplyModifiedProperties();
    }
 public override void OnInspectorGUI()
 {
     serializedObject.Update();
     //disableMargin = true;
     //UseDefaultMargins();
     flowchart.graph = (VCSUGraph)EditorGUILayout.ObjectField("Graph", flowchart.graph, typeof(VCSUGraph), true);
     if (flowchart.graph)
     {
         if (AssetDatabase.Contains(flowchart.graph))
         {
             flowchart.graph = VCSUObject.Clone(flowchart.graph);
         }
     }
     if (!EditorApplication.isPlaying)
     {
         if (GUILayout.Button("Generate Test Script"))
         {
             var dc = new DynamicClass();
             dc.Import(flowchart.graph);
             dc.Export();
         }
     }
     GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);
     if (GUILayout.Button("Open Graph"))
     {
         FlowchartEditorWindow.Init(flowchart.graph);
     }
     if (GUILayout.Button("Revert To Original"))
     {
         var oGraph = (VCSUGraph)EditorUtility.InstanceIDToObject(flowchart.graph.OriginalIID);
         if (!oGraph)
         {
             oGraph = AssetDatabase.LoadAssetAtPath <VCSUGraph>(flowchart.graph.OriginalPath);
         }
         if (oGraph)
         {
             flowchart.graph = VCSUObject.Clone(oGraph);
         }
     }
     if (GUILayout.Button("Apply To Original Graph"))
     {
         var oGraph = (VCSUGraph)EditorUtility.InstanceIDToObject(flowchart.graph.OriginalIID);
         if (!oGraph)
         {
             oGraph = AssetDatabase.LoadAssetAtPath <VCSUGraph>(flowchart.graph.OriginalPath);
         }
         if (oGraph)
         {
             VCSUObject.ApplyFromClone(flowchart.graph, oGraph);
         }
     }
     GUILayout.EndHorizontal();
     if (variables != null)
     {
         XmlDictionary <string, VariableTest> renameds = new XmlDictionary <string, VariableTest>();
         foreach (var variable in variables)
         {
             var frect    = EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
             var fboxRect = new Rect(frect.x, frect.y - 1.5f, frect.width + 1, frect.height + 2.5f);
             GUI.Box(fboxRect, "");
             GUI.Button(new Rect(frect.x + 5, frect.center.y - 7.5f, 20, 20), '\u003D'.ToString(), GUIStyle.none);
             var name = variable.Value.name;
             GUILayout.BeginHorizontal();
             GUILayout.Space(15);
             variable.Value.name = EditorGUILayout.TextField(variable.Value.name);
             GUILayout.EndHorizontal();
             var variableType = variable.Value.variableType;
             GUILayout.BeginHorizontal();
             GUILayout.Space(15);
             variable.Value.variableType = (VariableType)EditorGUILayout.EnumPopup(variable.Value.variableType);
             GUILayout.EndHorizontal();
             if (variableType != variable.Value.variableType)
             {
                 GUIChanged = true;
             }
             Tuple <bool, object> value = null;
             GUILayout.BeginHorizontal();
             GUILayout.Space(15);
             if (variable.Value.variableType != VariableType.Object)
             {
                 value = GUIExtended.DrawGUISwitch(variable.Value.variableType.ToString(), variable.Value.value);
             }
             else
             {
                 value = GUIExtended.DrawGUIUObject(variable.Value.value);
             }
             GUILayout.EndHorizontal();
             if (value != null)
             {
                 if (value.Item1 == true)
                 {
                     GUIChanged = true;
                 }
                 variable.Value.value = value.Item2;
             }
             if (name != variable.Value.name)
             {
                 renameds.Add(variable.Key, variable.Value);
             }
             EditorGUILayout.EndVertical();
         }
         foreach (var renamed in renameds)
         {
             var index = variables.Values.IndexOf(renamed.Value);
             variables.RemoveAt(index);
             if (variables.Count < index)
             {
                 variables.Add(renamed.Key, renamed.Value);
             }
             else
             {
                 variables.Insert(index, new XmlKeyValuePair <string, VariableTest>(renamed.Key, renamed.Value));
             }
         }
         var trect    = EditorGUILayout.BeginHorizontal(EditorStyles.inspectorFullWidthMargins);
         var rect     = GUILayoutUtility.GetRect(trect.width, trect.height + 16);
         var tboxRect = new Rect(trect.x, rect.y, trect.width - 30, rect.height);
         TempVariable = EditorGUI.TextField(tboxRect, TempVariable);
         if (GUI.Button(new Rect(trect.width - 30, rect.y, 30, rect.height), '\u002B'.ToString()) && !string.IsNullOrEmpty(TempVariable))
         {
             var variable = new VariableTest();
             variable.name = TempVariable;
             variables.Add(TempVariable, variable);
             TempVariable = string.Empty;
             GUIChanged   = true;
         }
         if (string.IsNullOrEmpty(TempVariable))
         {
             EditorGUI.LabelField(tboxRect, "(New Variable Name)", TempLable());
         }
         EditorGUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("REMOVE"))
         {
             if (variables.Count > 0)
             {
                 variables.RemoveAt(variables.IndexOf(variables.Last()));
                 GUIChanged = true;
             }
         }
         GUILayout.EndHorizontal();
     }
     if (variables != null && variables.Count > 0)
     {
         SerializeData();
     }
     serializedObject.ApplyModifiedProperties();
 }
 public void DrawBezierPreview(Vector2 knobeCenter)
 {
     DrawBezier(FlowchartEditorWindow.GraphToScreenSpace(knobeCenter), Event.current.mousePosition, Color.white);
 }
    public void DrawSymboles()
    {
        int id = 0;

        if (selections != null && selections.Count > 0)
        {
            id = selections[0];
        }
        for (int i = 0; i < symboles.Count; i++)
        {
            var area = symboles[i].NodeSize;
            area.position = FlowchartEditorWindow.GraphToScreenSpace(area.position);
            GUI.Box(area, symboles[i].name.AddWordSpace(), background);
            GUILayout.BeginArea(new Rect(area.position.x - 8, area.position.y + 35, area.width + 16, area.height - 35));
            var r  = EditorGUILayout.BeginVertical();
            var lw = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 80;
            if (symboles[i].fieldPoints != null)
            {
                foreach (var point in symboles[i].fieldPoints)
                {
                    point.Draw();
                }
            }
            symboles[i].OnGUI();
            EditorGUIUtility.labelWidth = lw;
            EditorGUILayout.EndVertical();
            GUILayout.EndArea();
            if (r.height > 0)
            {
                symboles[i].NodeSize.height = area.height = 43 + r.height;
            }
            if (symboles[i].shouldCall && symboles[i].Call)
            {
                symboles[i].Call.Draw(few.pOffset);
            }
            if (symboles[i].shouldReceive && symboles[i].Receive)
            {
                symboles[i].Receive.Draw(few.pOffset);
            }
            if (symboles[i] == selectedSymbole)
            {
                GUI.Box(area, "", highlighted);
            }
        }
        if (ShowThread)
        {
            time += Time.deltaTime;
        }
        for (int i = 0; i < symboles.Count; i++)
        {
            var area = symboles[i].NodeSize;
            area.position = FlowchartEditorWindow.GraphToScreenSpace(area.position);
            if (symboles[i].GetInstanceID() == id && ShowThread && time > Mathf.Clamp(UpdateTime, 0.4f, 0.6f))
            {
                GUI.Box(area, "", highlighted);
                selections.Remove(id);
                time        = 0;
                GUI.changed = true;
            }
        }
    }