Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Space(20);

        prevSelectedToolbar = selectedToolbar;
        selectedToolbar     = GUILayout.Toolbar(selectedToolbar, toolbarButtons);

        creator.curveEditing = selectedToolbar == 1;
        if (prevSelectedToolbar != selectedToolbar)
        {
            SceneView.RepaintAll();
            Repaint();
        }


        GUILayout.Space(40);

        if (selectedToolbar == 0)
        {
            if (GUILayout.Button("Stick Nodes to Ground"))
            {
                StickNodesToGround();
            }
            if (GUILayout.Button("Reassign IDs"))
            {
                for (int i = 0; i < creator.transform.childCount; i++)
                {
                    int       id    = i + 1;
                    Transform child = creator.transform.GetChild(i);
                    child.GetComponent <Node>().SetID(id);
                    child.name = "NODE_" + id;
                }

                SerializableStretchesDictionary stretches = new SerializableStretchesDictionary();

                for (int i = 0; i < creator.stretches.Count; i++)
                {
                    Vector2Int key = creator.GenerateKey(creator.stretches.ElementAt(i).Value.anchorA.GetID(),
                                                         creator.stretches.ElementAt(i).Value.anchorB.GetID());
                    stretches.Add(key, creator.stretches.ElementAt(i).Value);
                    Debug.Log(key);
                }

                creator.stretches = stretches;
            }
        }
    }
Esempio n. 2
0
    //Devuelve el tramo que conecta un node de la lista con el siguiente. El anterior si !forward
    private Stretch GetStretch(int nodeIndex, bool forward = true)
    {
        int x = nodes[LoopNodeIndex(nodeIndex)].GetID();

        nodeIndex = forward ? (nodeIndex + 1) : (nodeIndex - 1);
        int y = nodes[LoopNodeIndex(nodeIndex)].GetID();

        Vector2Int key = nodeNetCreator.GenerateKey(x, y);

        Stretch st = null;

        try
        {
            st = nodeNetCreator.stretches[key];
        }
        catch
        {
            Debug.LogAssertion(key);
        }

        return(st);
    }