public void SetStaticReferance()
 {
     if (graph)
     {
         _graph = graph;
     }
 }
Ejemplo n.º 2
0
 public static void Init(VCSUGraph graph)
 {
     if (graph)
     {
         FlowchartEditorWindow few = GetWindow <FlowchartEditorWindow>();
         few.titleContent = new GUIContent("VisualCS Unity");
         few.Load(graph);
         few.Show();
     }
 }
Ejemplo n.º 3
0
    private static void SerializeData(VCSUGraph graph)
    {
        XmlSerializer xmlSerializer = new XmlSerializer(typeof(XmlDictionary <string, VariableTest>));

        using (StringWriter writer = new StringWriter())
        {
            xmlSerializer.Serialize(writer, graph.variables);
            graph.XmlData = writer.ToString();
        }
        EditorUtility.SetDirty(graph);
        AssetDatabase.SaveAssets();
    }
Ejemplo n.º 4
0
 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);
         }
     }
 }
Ejemplo n.º 5
0
    public static VCSUGraph Clone(VCSUGraph graph)
    {
        var clone = ScriptableObject.CreateInstance <VCSUGraph>();

        if (graph.symboles != null)
        {
            clone.symboles = new List <Symbole>();

            foreach (var symbole in graph.symboles)
            {
                var tmp = UnityEngine.Object.Instantiate(symbole);
                tmp.fieldPoints.Clear();
                clone.symboles.Add(tmp);
            }

            if (graph.connectionPoints != null)
            {
                clone.connectionPoints = graph.connectionPoints.Select(x => UnityEngine.Object.Instantiate(x)).ToList();
                List <int> indexs = new List <int>();
                foreach (var point in clone.connectionPoints)
                {
                    var sIndex = graph.symboles.IndexOf(point.symbole);
                    var pIndex = clone.connectionPoints.IndexOf(point);
                    point.symbole = clone.symboles[sIndex];
                    if (graph.connectionPoints[pIndex].Connections != null && graph.connectionPoints[pIndex].Connections.Count > 0)
                    {
                        indexs = graph.connectionPoints[pIndex].Connections.Select(x => graph.connectionPoints.IndexOf(x)).ToList();
                        point.Connections.Clear();
                        foreach (var index in indexs)
                        {
                            point.AddConnection(clone.connectionPoints[index]);
                        }
                    }
                    point.symbole.fieldPoints.Add(point);
                }
            }
            clone.variables = graph.variables;
            SerializeData(clone);
            clone.OriginalIID  = graph.GetInstanceID();
            clone.OriginalPath = AssetDatabase.GetAssetOrScenePath(clone);
        }
        return(clone);
    }
Ejemplo n.º 6
0
    public static void ApplyFromClone(VCSUGraph graph, VCSUGraph OriginalGraph)
    {
        if (graph.symboles != null)
        {
            OriginalGraph.symboles = new List <Symbole>();

            OriginalGraph.symboles.Clear();
            foreach (var symbole in graph.symboles)
            {
                var tmp = UnityEngine.Object.Instantiate(symbole);
                tmp.fieldPoints.Clear();
                OriginalGraph.symboles.Add(tmp);
            }

            if (graph.connectionPoints != null)
            {
                OriginalGraph.connectionPoints.Clear();
                OriginalGraph.connectionPoints = graph.connectionPoints.Select(x => UnityEngine.Object.Instantiate(x)).ToList();
                List <int> indexs = new List <int>();
                foreach (var point in OriginalGraph.connectionPoints)
                {
                    var sIndex = graph.symboles.IndexOf(point.symbole);
                    var pIndex = OriginalGraph.connectionPoints.IndexOf(point);
                    point.symbole = OriginalGraph.symboles[sIndex];
                    Debug.Log(graph.connectionPoints[pIndex].Connections != null && graph.connectionPoints[pIndex].Connections.Count > 0);
                    if (graph.connectionPoints[pIndex].Connections != null && graph.connectionPoints[pIndex].Connections.Count > 0)
                    {
                        indexs = graph.connectionPoints[pIndex].Connections.Select(x => graph.connectionPoints.IndexOf(x)).ToList();
                        point.Connections.Clear();
                        foreach (var index in indexs)
                        {
                            point.AddConnection(OriginalGraph.connectionPoints[index]);
                        }
                    }
                    point.symbole.fieldPoints.Add(point);
                }
            }
            OriginalGraph.variables = graph.variables;
            SerializeData(OriginalGraph);
        }
    }
 public void Import(VCSUGraph graph)
 {
     for (int i = 0; i < graph.symboles.Count; i++)
     {
         if (!NameSpace.Contains(graph.symboles[i].GetNameSpace()))
         {
             NameSpace.Add(graph.symboles[i].GetNameSpace());
         }
     }
     Name = graph.name;
     if (string.IsNullOrEmpty(Name))
     {
         Name = "Test" + ((GetHashCode() < 0) ? GetHashCode() * -1 : GetHashCode());
     }
     foreach (var variable in graph.variables)
     {
         Fields.Add(string.Format("public {0} {1};", variable.Value.variableType, variable.Key));
     }
     for (int i = 0; i < graph.CallsValue.Count; i++)
     {
         Debug.Log(graph.symboles[graph.CallsValue[i]].name);
         Methods.Add(graph.symboles[graph.CallsValue[i]].ToString());
     }
 }