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

        labelStyle.normal.textColor = netDisplaySettings.guiStyle.normal.textColor;

        GUILayout.Space(20);

        if (GUILayout.Button("Stick Nodes to Ground"))
        {
            StickNodesToGround();
        }

        if (GUILayout.Button("Recalculate Vertices"))
        {
            for (int i = 0; i < creator.NStretches; i++)
            {
                Stretch st = creator.GetStretch(i);
                st.OnPathModified();
            }
        }

        if (GUILayout.Button("Reassign Nodes"))
        {
            for (int i = 0; i < creator.NNodes; i++)
            {
                Node n = creator.GetNode(i);
                n.id             = i;
                n.transform.name = "NODE_" + i;
            }
        }

        if (GUILayout.Button("Print curvature percentages"))
        {
            for (int i = 0; i < creator.NStretches; i++)
            {
                Stretch st = creator.GetStretch(i);
                Debug.Log("Stretch: " + st.Name + ": " + PathCreation.Utility.CubicBezierUtility.AproximateAmountOfCurvature(st.GetPoints()));
            }
        }

        GUILayout.Space(20);

        if (GUILayout.Button("Load from xml file"))
        {
            creator.LoadFromXml();
        }
        if (GUILayout.Button("Save to xml file"))
        {
            creator.SaveToXml();
        }

        GUILayout.Space(20);

        if (selectedNode != null)
        {
        }

        DrawNetDisplaySettingsInspector();
    }
Ejemplo n.º 2
0
 private void OnUndoNodeDelete()
 {
     for (int i = 0; i < creator.NStretches; i++)
     {
         Stretch st = creator.GetStretch(i);
         st.OnPathModified();
     }
 }
Ejemplo n.º 3
0
    private void MoveHandler(Stretch st, Stretch.CurveSide side, ref bool elementClicked)
    {
        float buttonRadius = netDisplaySettings.handlerRadius;

        Handles.color = netDisplaySettings.handlerColor;

        Vector3    handlerInitialPos;
        Quaternion handlerRot = Quaternion.identity;
        Vector3    newPos;

        switch (side)
        {
        case Stretch.CurveSide.A:
            handlerInitialPos = st.ControlA;
            handlerRot        = Quaternion.LookRotation(Camera.current.transform.position - handlerInitialPos);
            EditorGUI.BeginChangeCheck();
            newPos = Handles.PositionHandle(handlerInitialPos, Quaternion.identity);
            if (EditorGUI.EndChangeCheck())
            {
                st.OnPathModified();
                Undo.RecordObject(creator, "Move ControlA");
                EditorUtility.SetDirty(creator);

                Vector3 oldPos = st.ControlA;
                st.ControlA = newPos;
                if (Event.current.shift)
                {
                    DoMirrorPairs(st, st.AnchorA, oldPos, newPos);
                }
            }
            if (Handles.Button(st.ControlB, Quaternion.identity, buttonRadius, buttonRadius, Handles.SphereHandleCap))
            {
                selectedControlPointSide = Stretch.CurveSide.B;
                selectedNode             = null;
                transformingNode         = false;
                elementClicked           = true;
            }
            break;

        case Stretch.CurveSide.B:
            handlerInitialPos = st.ControlB;
            handlerRot        = Quaternion.LookRotation(Camera.current.transform.position - handlerInitialPos);
            EditorGUI.BeginChangeCheck();
            newPos = Handles.PositionHandle(handlerInitialPos, Quaternion.identity);
            if (EditorGUI.EndChangeCheck())
            {
                st.OnPathModified();
                Undo.RecordObject(creator, "Move ControlB");
                EditorUtility.SetDirty(creator);

                Vector3 oldPos = st.ControlB;
                st.ControlB = newPos;
                if (Event.current.shift)
                {
                    DoMirrorPairs(st, st.AnchorB, oldPos, newPos);
                }
            }
            if (Handles.Button(st.ControlA, Quaternion.identity, buttonRadius, buttonRadius, Handles.SphereHandleCap))
            {
                selectedControlPointSide = Stretch.CurveSide.A;
                selectedNode             = null;
                transformingNode         = false;
                elementClicked           = true;
            }
            break;
        }

        Handles.DrawLine(st.ControlA, st.AnchorA.Pos);
        Handles.DrawLine(st.ControlB, st.AnchorB.Pos);
        SceneView.RepaintAll();
    }