Skip to content

Commit

Permalink
added auto-activation when in timeline clip
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonm-unity committed Aug 24, 2017
1 parent c308cb5 commit 225f350
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class AlembicShotAsset : PlayableAsset, ITimelineClipAsset
[Tooltip("Portion, in seconds, of the alembic stream used by the shot.")]
[ReadOnly] public float m_AlembicLength = 0;

[Tooltip("Auto active/deactivate GameObject on Play/Pause")]
[SerializeField] public bool m_AutoActivateTarget = true;

public ClipCaps clipCaps { get { return ClipCaps.None; } }

public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
Expand All @@ -41,6 +44,7 @@ public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
behaviour.m_EndTimeClipOff = m_EndOffset;
behaviour.m_TimeScale = m_TimeScale;
behaviour.m_Cycle = m_Cycle;
behaviour.m_AutoActivateTarget = m_AutoActivateTarget;
return playable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ public AlembicStreamPlayer streamPlayer
}
}

bool m_RestoreState = false;
bool m_OrgState;
public float m_StartTimeOffset;
public float m_EndTimeClipOff;
public float m_TimeScale;
public bool m_AutoActivateTarget;
public AlembicPlaybackSettings.CycleType m_Cycle = AlembicPlaybackSettings.CycleType.Hold;

public override void ProcessFrame(Playable playable, FrameData info, object playerData)
Expand All @@ -44,6 +47,33 @@ public override void ProcessFrame(Playable playable, FrameData info, object play

streamPlayer.ManualUpdate();
}

public override void OnBehaviourPlay(Playable playable, FrameData info)
{
base.OnBehaviourPlay(playable, info);

if (streamPlayer == null)
return;

if (m_AutoActivateTarget)
{
m_RestoreState = true;
m_OrgState = streamPlayer.gameObject.activeInHierarchy;
streamPlayer.gameObject.SetActive(true);
}
}

public override void OnBehaviourPause(Playable playable, FrameData info)
{
base.OnBehaviourPause(playable, info);

if (streamPlayer == null)
return;

if( m_AutoActivateTarget && m_RestoreState )
streamPlayer.gameObject.SetActive(m_OrgState);

}
}
}

Expand Down

0 comments on commit 225f350

Please sign in to comment.