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 24eef7b commit b50b787
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 25 additions & 11 deletions Runtime/Listeners/TimelineTriggerEventListener.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
using UnityEngine.Serialization;
Expand Down Expand Up @@ -63,31 +64,44 @@ private void Respond(PlayableAsset timeline, bool value)
{
isStop = false;
_playableDirectorToControl.Play();
_lastPlayableState = _playableDirectorToControl.state;
_lastPlayableState = PlayState.Playing;
}
else
{
isStop = true;
_playableDirectorToControl.Stop();
_lastPlayableState = _playableDirectorToControl.state;
_lastPlayableState = PlayState.Paused;
}

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

private void Pause(bool state)
private void Pause(bool state) // true = pause ... false = unpause
{
switch (state && !isStop)
if(isStop) return;

switch (_lastPlayableState)
{
case true when _lastPlayableState == PlayState.Playing:
_playableDirectorToControl.Pause();
_lastPlayableState = _playableDirectorToControl.state;
case PlayState.Playing:
if (state)
{
_playableDirectorToControl.Pause();
_lastPlayableState = PlayState.Paused;
}
break;

case false when _lastPlayableState == PlayState.Paused:
_playableDirectorToControl.Play();
_lastPlayableState = _playableDirectorToControl.state;
case PlayState.Paused:
if (!state)
{
isStop = false;
_playableDirectorToControl.Play();
_lastPlayableState = PlayState.Playing;
}
break;
case PlayState.Delayed:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
Expand Down
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.117",
"version": "0.1.118",
"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 b50b787

Please sign in to comment.