Skip to content

Commit 225f350

Browse files
committed
added auto-activation when in timeline clip
1 parent c308cb5 commit 225f350

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

AlembicImporter/Assets/UTJ/Alembic/Scripts/Timeline/AlembicShotAsset.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class AlembicShotAsset : PlayableAsset, ITimelineClipAsset
2929
[Tooltip("Portion, in seconds, of the alembic stream used by the shot.")]
3030
[ReadOnly] public float m_AlembicLength = 0;
3131

32+
[Tooltip("Auto active/deactivate GameObject on Play/Pause")]
33+
[SerializeField] public bool m_AutoActivateTarget = true;
34+
3235
public ClipCaps clipCaps { get { return ClipCaps.None; } }
3336

3437
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
@@ -41,6 +44,7 @@ public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
4144
behaviour.m_EndTimeClipOff = m_EndOffset;
4245
behaviour.m_TimeScale = m_TimeScale;
4346
behaviour.m_Cycle = m_Cycle;
47+
behaviour.m_AutoActivateTarget = m_AutoActivateTarget;
4448
return playable;
4549
}
4650

AlembicImporter/Assets/UTJ/Alembic/Scripts/Timeline/AlembicShotPlayable.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ public AlembicStreamPlayer streamPlayer
2222
}
2323
}
2424

25+
bool m_RestoreState = false;
26+
bool m_OrgState;
2527
public float m_StartTimeOffset;
2628
public float m_EndTimeClipOff;
2729
public float m_TimeScale;
30+
public bool m_AutoActivateTarget;
2831
public AlembicPlaybackSettings.CycleType m_Cycle = AlembicPlaybackSettings.CycleType.Hold;
2932

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

4548
streamPlayer.ManualUpdate();
4649
}
50+
51+
public override void OnBehaviourPlay(Playable playable, FrameData info)
52+
{
53+
base.OnBehaviourPlay(playable, info);
54+
55+
if (streamPlayer == null)
56+
return;
57+
58+
if (m_AutoActivateTarget)
59+
{
60+
m_RestoreState = true;
61+
m_OrgState = streamPlayer.gameObject.activeInHierarchy;
62+
streamPlayer.gameObject.SetActive(true);
63+
}
64+
}
65+
66+
public override void OnBehaviourPause(Playable playable, FrameData info)
67+
{
68+
base.OnBehaviourPause(playable, info);
69+
70+
if (streamPlayer == null)
71+
return;
72+
73+
if( m_AutoActivateTarget && m_RestoreState )
74+
streamPlayer.gameObject.SetActive(m_OrgState);
75+
76+
}
4777
}
4878
}
4979

0 commit comments

Comments
 (0)