示例#1
0
    private void DrawNode(Node node, ref bool elementClicked)
    {
        float radius = netDisplaySettings.nodeRadius;

        Handles.color = netDisplaySettings.nodeColor;

        if (node == selectedNode && transformingNode)
        {
            EditorGUI.BeginChangeCheck();
            Vector3 newPos = Handles.PositionHandle(node.Pos, Quaternion.identity);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(node.transform, "node moved");
                node.Pos = newPos;
                foreach (Stretch st in creator.GetStretches(node))
                {
                    st.OnPathModified();
                }
            }
        }
        else
        {
            if (Handles.Button(node.Pos, Quaternion.identity, radius, radius, Handles.SphereHandleCap))
            {
                //Delete node
                if (Event.current.modifiers == EventModifiers.Control)
                {
                    if (selectedNode == node)
                    {
                        selectedNode = null;
                    }
                    creator.DeleteNode(node);
                }
                //Select node to move
                else
                {
                    if (selectedNode == node)
                    {
                        float clickTime = Time.time;
                        if ((clickTime - lastClickTime) < 0.2f)
                        {
                            transformingNode = true;
                            selectedStretch  = null;
                        }
                    }
                    if (selectedNode != null && !transformingNode)
                    {
                        Undo.RecordObject(creator, "Stretch added");
                        Stretch st = creator.CreateStretch(selectedNode, node);
                    }
                    selectedStretch = null;
                    selectedNode    = node;
                    elementClicked  = true;

                    lastClickTime = Time.time;
                }
            }
        }
    }