Footprint.CreateEdges C# (CSharp) Method

CreateEdges() public method

public CreateEdges ( ) : void
return void
    public void CreateEdges()
    {
        edges = new List<Edge>();

        for (int i = 0; i < nodes.Count; i++)
        {
            Node cur = nodes[i];
            Node other;

            if (i == nodes.Count - 1)
                other = nodes[0];
            else
                other = nodes[i + 1];

            edges.Add(new Edge(cur.ID, other.ID));
        }
    }
}

Usage Example

Example #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (footprint.nodes == null)
        {
            footprint.nodes = new List <Node>();
        }

        if (GUILayout.Button("Add Node", GUILayout.Width(120f)))
        {
            footprint.nodes.Add(new Node());
        }

        if (GUILayout.Button("Create edges", GUILayout.Width(120f)))
        {
            footprint.CreateEdges();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(footprint);
        }
    }