示例#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;
            }
        }
    }