Search Unity

Playable drawer get ExposedReference position

Discussion in 'Timeline' started by mammouth31, Apr 7, 2019.

  1. mammouth31

    mammouth31

    Joined:
    Feb 1, 2013
    Posts:
    1
    Hello,
    I'm trying to modify the TransformTween playable. I would like the clip duration to be automatically modified depending on the distance between de start location and the end location.
    I added these lines at the end of TransformTweenDrawer.cs

    Code (CSharp):
    1.  
    2. TransformTweenClip clip = property.serializedObject.targetObject as TransformTweenClip;
    3. SerializedObject editorGUI = new SerializedObject(Selection.activeObject);
    4. SerializedProperty duration = editorGUI.FindProperty("m_Clip.m_Duration");
    5.  // duration.doubleValue = 3f;
    6. duration.doubleValue= Vector3.Distance(clip.startLocation.position, clip.endLocation.position);
    7. editorGUI.ApplyModifiedProperties();
    8.  
    I get an error 'ExposedReference<Transform>' does not contain a definition for 'position'...
    I think it's because startLocation and endLocation are ExposedReference<Transform> but I have no idea how to handle them.
    Thank for your help
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The playable director contains the table for looking up the transforms.
    e.g.
    var transformA = playableDirector.GetReferenceValue(clip.startLocation.exposedName, out valid) as Transform;

    If you need the current PlayableDirector in the editor window, you can use TimelineEditor.inspectedDirector;