public float EstimateSegmentLength(int segment, int subdivisions = 50)
    {
        float num = 0f;

        Debug.Assert(nodes.Length > segment, "Invalid segment number.");
        SmoothBezierNode smoothBezierNode  = nodes[segment];
        SmoothBezierNode smoothBezierNode2 = nodes[segment + 1];
        Transform        transform         = smoothBezierNode.transform;
        Transform        transform2        = smoothBezierNode2.transform;
        Vector3          position          = transform.position;
        Vector3          p         = transform.position + transform.forward * smoothBezierNode.OutHandleLength;
        Vector3          p2        = transform2.position - transform2.forward * smoothBezierNode2.InHandleLength;
        Vector3          position2 = transform2.position;
        Vector3          zero      = Vector3.zero;
        Vector3          vector    = BezierMath.Interpolate(position, p, p2, position2, 0f);
        float            num2      = 1f / (float)subdivisions;

        for (int i = 0; i < subdivisions; i++)
        {
            zero   = vector;
            vector = BezierMath.Interpolate(position, p, p2, position2, num2 * (float)(i + 1));
            num   += Vector3.Distance(zero, vector);
        }
        return(num);
    }
 private void CreateNode()
 {
     if (NodeContainer != null)
     {
         GameObject       gameObject       = new GameObject("Node" + NodeContainer.transform.childCount.ToString());
         SmoothBezierNode smoothBezierNode = gameObject.AddComponent <SmoothBezierNode>();
         smoothBezierNode.InHandleLength  = 0f;
         smoothBezierNode.OutHandleLength = 0f;
         gameObject.transform.position    = base.transform.position;
         gameObject.transform.parent      = NodeContainer.transform;
     }
 }
    public Vector3 InterpolateSegment(int segment, float u)
    {
        Debug.Assert(nodes.Length > segment, "Invalid segment number.");
        SmoothBezierNode smoothBezierNode  = nodes[segment];
        SmoothBezierNode smoothBezierNode2 = nodes[segment + 1];
        Transform        transform         = smoothBezierNode.transform;
        Transform        transform2        = smoothBezierNode2.transform;
        Vector3          position          = transform.position;
        Vector3          p         = transform.position + transform.forward * smoothBezierNode.OutHandleLength;
        Vector3          p2        = transform2.position - transform2.forward * smoothBezierNode2.InHandleLength;
        Vector3          position2 = transform2.position;

        return(BezierMath.Interpolate(position, p, p2, position2, u));
    }