// Layout-Rules:
    // Comments stay where they are
    // unconnected nodes stay where they are
    // Decision nodes are centered above their following nodes.
    // For-Each/For-Each-File: Subplan is put right
    // all other nodes are layouted top down.
    public void Relayout(UTGraph graph, UTNode startingNode)
    {
        if ( startingNode == null) {
            return;
        }

        this.graph = graph;
        columns.Clear();
        rows.Clear();
        visitedNodes.Clear();
        ProcessNode(startingNode, 0, 0);
        DoLayout();
    }
Exemplo n.º 2
0
    // Layout-Rules:
    // Comments stay where they are
    // unconnected nodes stay where they are
    // Decision nodes are centered above their following nodes.
    // For-Each/For-Each-File: Subplan is put right
    // all other nodes are layouted top down.

    public void Relayout(UTGraph graph, UTNode startingNode)
    {
        if (startingNode == null)
        {
            return;
        }

        this.graph = graph;
        columns.Clear();
        rows.Clear();
        visitedNodes.Clear();
        ProcessNode(startingNode, 0, 0);
        DoLayout();
    }
Exemplo n.º 3
0
    /// <summary>
    /// Clears the unused entries in the automation plan asset located at the given path. This is necessary
    /// because we support undo/redo with the visual editor and therefore don't delete automation plan entries
    /// when they are removed from the graphical view. The unused entries are cleared when the plan is saved.
    /// </summary>
    /// <param name='path'>
    /// Path.
    /// </param>
    /// <seealso cref="UTSaveInterceptor"/>
    public static void ClearUnusedEntriesIn(string path)
    {
        var asset = AssetDatabase.LoadMainAssetAtPath(path);

        if (asset is UTAutomationPlan)
        {
            var     plan      = (UTAutomationPlan)asset;
            UTGraph graph     = null;
            var     allAssets = AssetDatabase.LoadAllAssetsAtPath(path);
            var     entries   = new List <UTAutomationPlanEntry> ();
            foreach (var anAsset in allAssets)
            {
                if (anAsset is UTGraph)
                {
                    graph = (UTGraph)anAsset;
                }
                if (anAsset is UTAutomationPlanEntry)
                {
                    entries.Add((UTAutomationPlanEntry)anAsset);
                }
            }

            var deps = EditorUtility.CollectDependencies(new UObject[] { plan, graph });
            foreach (var dep in deps)
            {
                if (dep is UTAutomationPlanEntry)
                {
                    entries.Remove((UTAutomationPlanEntry)dep);
                }
            }

            if (UTPreferences.DebugMode && entries.Count > 0)
            {
                Debug.Log("Clearing " + entries.Count + " leaked entries from " + plan.name + ". This message is harmless.");
            }
            foreach (var entry in entries)
            {
                ScriptableObject.DestroyImmediate(entry, true);
            }

            UTStatistics.CleanUp();
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Loads a plan into this model.
    /// </summary>
    /// <param name='plan'>
    /// The plan to load.
    /// </param>
    public void LoadPlan(UTAutomationPlan plan)
    {
        if (plan != null)
        {
            data = plan;
            string path = PlanPath;
            graphData = null;
            selectedNodes.Clear();

            // objects with hide fagl are not returned by LoadAssetAtPath
            UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(path);
            foreach (UnityEngine.Object asset in assets)
            {
                if (asset is UTGraph)
                {
                    graphData = (UTGraph)asset;
                    break;
                }
            }
            if (graphData == null)
            {
                graphData      = UTils.AddAssetOfType <UTGraph> (path, true);
                graphData.name = "Graph";
                EditorUtility.SetDirty(graphData);
            }
            if (plan.firstEntry != null)
            {
                SelectNode(graphData.GetNodeFor(plan.firstEntry), SelectionMode.Add);
            }
        }
        else
        {
            data      = null;
            graphData = null;
            selectedNodes.Clear();
            highlightedNode = null;
        }
    }