コード例 #1
0
ファイル: PathEditor.cs プロジェクト: aguzmanc/PrototipoARPIL
    void Draw()
    {
        for (int i = 0; i < path.NumSegments; i++)
        {
            Vector2[] points = path.GetPointsInSegment(i);

            Handles.color = Color.black;
            Handles.DrawLine(ToV3(points [1]), ToV3(points [0]));
            Handles.DrawLine(ToV3(points [2]), ToV3(points [3]));
            Handles.DrawBezier(ToV3(points [0]), ToV3(points [3]), ToV3(points [1]), ToV3(points [2]), Color.green, null, 5);
        }

        Handles.color = Color.red;
        for (int i = 0; i < path.NumPoints; i++)
        {
            Vector3 newPos = Handles.FreeMoveHandle(ToV3(path [i]), Quaternion.identity, .1f, Vector3.zero, Handles.CylinderHandleCap);

            if (ToV3(path [i]) != newPos)
            {
                Undo.RecordObject(creator, "Move point");
                path.MovePoint(i, ToV2(newPos));
            }
        }

        if (creator.ShowRawPositions)
        {
            Vector3[] allPoints = path.GetRawPoints(creator.PointsPerSegment);
            for (int i = 0; i < allPoints.Length; i++)
            {
                Debug.DrawRay(creator.transform.TransformPoint(allPoints [i]), Vector3.up * creator.DebugLinesWidth, Color.blue);
            }
        }


        if (creator.ShowMarkLines)
        {
            Vector3[] marks = creator.GetEquidistantPoints(creator.MarkLinesDistance);
            for (int i = 0; i < marks.Length; i++)
            {
                Debug.DrawRay(creator.transform.TransformPoint(marks [i]), Vector3.up * creator.DebugLinesWidth, Color.red);
            }
        }

        creator.GenerateMesh();
    }