public void GetCurves(List <HEU_Curve> curves, bool bEditableOnly)
        {
            if (_geoCurve != null && (!bEditableOnly || _geoCurve.IsEditable()))
            {
                curves.Add(_geoCurve);
            }

            foreach (HEU_PartData part in _parts)
            {
                HEU_Curve partCurve = part.GetCurve(bEditableOnly);
                if (partCurve != null)
                {
                    curves.Add(partCurve);
                }
            }
        }
Ejemplo n.º 2
0
	/// <summary>
	/// Update and draw the curves for the specified asset.
	/// Manages the interaction modes.
	/// </summary>
	/// <param name="asset"></param>
	public void UpdateSceneCurves(HEU_HoudiniAsset asset)
	{
	    _serializedCurvesCache.Clear();

	    // Filter out non-editable curves
	    _curves.Clear();
	    foreach (Object targetObject in targets)
	    {
		HEU_Curve curve = targetObject as HEU_Curve;
		if (curve != null && curve.IsEditable())
		{
		    _curves.Add(curve);
		}
	    }

	    if (_curves.Count == 0)
	    {
		return;
	    }

	    _currentCamera = Camera.current;

	    Color defaultHandleColor = Handles.color;

	    Event currentEvent = Event.current;
	    Vector3 mousePosition = HEU_EditorUI.GetMousePosition(ref currentEvent, _currentCamera);

	    int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
	    EventType eventType = currentEvent.GetTypeForControl(controlID);

	    EditorGUI.BeginChangeCheck();

	    // Keep track of curves that were updated so we can apply changes via serialization
	    List<SerializedObject> updatedCurves = new List<SerializedObject>();

	    if (_interactionMode == HEU_Curve.Interaction.VIEW)
	    {
		UpdateViewMode(asset, controlID, eventType, mousePosition, updatedCurves);
	    }
	    else if (_interactionMode == HEU_Curve.Interaction.ADD)
	    {
		UpdateAddMode(asset, controlID, eventType, mousePosition, updatedCurves);
	    }
	    else if (_interactionMode == HEU_Curve.Interaction.EDIT)
	    {
		UpdateEditMode(asset, controlID, eventType, mousePosition, updatedCurves);
	    }

	    if (EditorGUI.EndChangeCheck())
	    {
		foreach (SerializedObject serializedCurve in updatedCurves)
		{
		    serializedCurve.ApplyModifiedProperties();
		}
	    }

	    Handles.color = defaultHandleColor;

	    if (eventType == EventType.Layout)
	    {
		// Delay update the show info so that the error doesn't popup trying to draw elements during drawing.
		_showInfoRepaint = _showInfo;
	    }

	    DrawSceneInfo();
	}