Exemplo n.º 1
0
	private void EditModeDrawCurvePoints(Event currentEvent, EventType eventType, ref int numSelectedPoints, ref Bounds bounds, ref bool bInteractionOcurred)
	{
	    Color defaultHandleColor = Handles.color;

	    // First we draw all the curves, while drawing each point as button
	    // and collecting the selected points.
	    foreach (HEU_Curve curve in _curves)
	    {
		if (eventType == EventType.Repaint)
		{
		    // Draw the cooked curve using its vertices
		    DrawCurveUsingVertices(curve, _selectedCurveColor);
		}

		// During dragging, we draw the points in the drag logic later
		if (_dragMouseDown)
		{
		    continue;
		}

		// Now draw all the points, but tailor their visual style according to interaction
		List<Vector3> points = curve.GetAllPoints();

		List<int> selectedPoints = new List<int>();
		_selectedCurvePoints.TryGetValue(curve.CurveName, out selectedPoints);

		for (int i = 0; i < points.Count; ++i)
		{
		    Vector3 pointPos = curve.GetTransformedPosition(points[i]);
		    float pointSize = HEU_EditorUI.GetHandleSize(pointPos);
		    float pickSize = pointSize * 2f;

		    if (selectedPoints != null && selectedPoints.Contains(i))
		    {
			// Selected point
			numSelectedPoints++;

			if (numSelectedPoints == 1)
			{
			    bounds = new Bounds(pointPos, Vector3.zero);
			}
			else
			{
			    bounds.Encapsulate(pointPos);
			}

			if (selectedPoints.Count > 1 || _selectedCurvePoints.Keys.Count > 1)
			{
			    Handles.color = _selectedPointColor;
			    if (HEU_EditorUI.DrawSphereCapButton(pointPos, Quaternion.identity, pointSize, pickSize))
			    {
				if (currentEvent.control)
				{
				    DeselectPoint(curve.CurveName, i);
				}
				else
				{
				    SelectSinglePoint(curve, i);
				}
				bInteractionOcurred = true;
			    }
			    Handles.color = defaultHandleColor;
			}
		    }
		    else
		    {
			// Unselected point

			Handles.color = _unselectedPointColor;
			if (HEU_EditorUI.DrawSphereCapButton(pointPos, Quaternion.identity, pointSize, pickSize))
			{
			    if (currentEvent.control)
			    {
				SelectAddPoint(curve, i);
			    }
			    else
			    {
				SelectSinglePoint(curve, i);
			    }

			    bInteractionOcurred = true;
			}
		    }
		}
	    }
	}