Exemplo n.º 1
0
    public void ConnectPoints()
    {
        Debug.Log("Connecting Points");

        Segments.Clear();

        ControlPointSetup[] controlPoints = GetComponentsInChildren <ControlPointSetup>();

        float totalDistance = 0.0f;

        for (int i = 1; i < controlPoints.Length; i++)
        {
            ControlPointSetup cp1 = controlPoints[i - 1];
            ControlPointSetup cp2 = controlPoints[i];

            // calculate distance
            float distance = CalcDistance(cp1, cp2);

            Segment seg = new Segment()
            {
                PointA             = cp1, PointB = cp2,
                Length             = distance,
                StartAccumDistance = totalDistance,
            };

            Segments.Add(seg);
            totalDistance += distance;
        }
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        ControlPointSetup cp = target as ControlPointSetup;

        if (cp == null)
        {
            return;
        }

        base.OnInspectorGUI();
    }
Exemplo n.º 3
0
    public void OnSceneGUI()
    {
        ControlPointSetup cp = target as ControlPointSetup;

        if (cp == null)
        {
            return;
        }

        Handles.color = Color.white;
        Handles.DrawLine(cp.transform.position, cp.transform.position + cp.HandleA);
        Handles.DrawLine(cp.transform.position, cp.transform.position + cp.HandleB);

        mHandleTransform = cp.transform;
        mHandleRotation  = Tools.pivotRotation == PivotRotation.Local ? mHandleTransform.rotation : Quaternion.identity;

        for (int i = 0; i < ControlPointSetup.NUM_HANDLES; i++)
        {
            if (Handles.Button(cp.transform.position + cp.GetHandle(i), mHandleRotation, HANDLE_SIZE, PICK_SIZE, Handles.DotCap))
            {
                mSelectedHandle = i;
            }

            if (mSelectedHandle == i)
            {
                EditorGUI.BeginChangeCheck();
                Vector3 point = Handles.DoPositionHandle(cp.transform.position + cp.GetHandle(i), mHandleRotation);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(cp, "Move Handle");
                    EditorUtility.SetDirty(cp);
                    cp.SetHandle(i, point - cp.transform.position);
                }
            }
        }
    }
Exemplo n.º 4
0
 public float CalcDistance(ControlPointSetup cp1, ControlPointSetup cp2)
 {
     return((cp1.transform.position - cp2.transform.position).magnitude);
 }