Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
lejeanf committed Aug 29, 2024
1 parent fba1516 commit 24eef7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions Runtime/Listeners/TimelineTriggerEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ public bool isDebug
public TimelineBoolEvent OnEventRaised;

[SerializeField] private BoolEventChannelSO generalPauseEvent;
private bool isStop = true;

private void OnEnable()
{
isStop = true;
if (_channel != null) _channel.OnEventRaised += Respond;
if (generalPauseEvent) generalPauseEvent.OnEventRaised += Pause;
}
Expand All @@ -59,31 +61,34 @@ private void Respond(PlayableAsset timeline, bool value)
OnEventRaised?.Invoke(timeline, value);
if (value)
{
isStop = false;
_playableDirectorToControl.Play();
_lastPlayableState = _playableDirectorToControl.state;
}
else
{
isStop = true;
_playableDirectorToControl.Stop();
_lastPlayableState = _playableDirectorToControl.state;
}

_lastPlayableState = _playableDirectorToControl.state;
if(isDebug) Debug.Log($" timeline-bool event raised: <{timeline},{value}>");
if(isDebug) Debug.Log($" timeline-bool event raised: <{timeline},{value}>, timelineState: {_playableDirectorToControl.state}");
}

private void Pause(bool state)
{
switch (state)
switch (state && !isStop)
{
case true when _lastPlayableState == PlayState.Playing:
_playableDirectorToControl.Pause();
_lastPlayableState = _playableDirectorToControl.state;
break;

case false when _lastPlayableState == PlayState.Paused:
_playableDirectorToControl.Play();
_lastPlayableState = _playableDirectorToControl.state;
break;
}

_lastPlayableState = _playableDirectorToControl.state;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fr.jeanf.eventsystem",
"version": "0.1.116",
"version": "0.1.117",
"displayName": "Event System",
"description": "This package contains a basic Event System based on Scriptable Objects as communication medium",
"unity": "2021.3",
Expand Down

0 comments on commit 24eef7b

Please sign in to comment.