Example #1
0
 public void Reset(Spline2DRoadComponent path)
 {
     onDeath            = null;
     onPathFinished     = null;
     this.path          = path;
     distanceTraveled   = 0;
     transform.position = path.GetPointWorldSpace(0);
     health             = m_maxHealth;
 }
Example #2
0
    private void ShowPoint(int index)
    {
        Vector3 point = spline.GetPointWorldSpace(index);

        Vector3[] sidePoints = spline.GetSidePointsWorldSpace(index);
        float     size       = HandleUtility.GetHandleSize(point);

        if (index == 0)
        {
            Handles.color = Color.green;
        }
        else if (index == spline.Count - 1 && !spline.IsClosed)
        {
            Handles.color = Color.red;
        }
        else
        {
            Handles.color = Color.cyan;
        }

        if (Handles.Button(point, Quaternion.identity, size * handleSize, size * pickSize, Handles.DotCap))
        {
            selectedIndex = index;
            Repaint();
        }
        if (selectedIndex == index)
        {
            EditorGUI.BeginChangeCheck();
            point = Handles.FreeMoveHandle(point, Quaternion.identity, size * 1.5f * handleSize, Vector3.zero, Handles.CircleCap);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(spline, "Move Point");
                EditorUtility.SetDirty(spline);
                spline.SetPointWorldSpace(index, point);
            }
        }
    }