diff --git a/UnityProject/.idea/.idea.UnityProject/.idea/contentModel.xml b/UnityProject/.idea/.idea.UnityProject/.idea/contentModel.xml
index 115f7f6..b6143fc 100644
--- a/UnityProject/.idea/.idea.UnityProject/.idea/contentModel.xml
+++ b/UnityProject/.idea/.idea.UnityProject/.idea/contentModel.xml
@@ -136,6 +136,7 @@
+
diff --git a/UnityProject/.idea/.idea.UnityProject/.idea/workspace.xml b/UnityProject/.idea/.idea.UnityProject/.idea/workspace.xml
index 57b28d1..9fd534d 100644
--- a/UnityProject/.idea/.idea.UnityProject/.idea/workspace.xml
+++ b/UnityProject/.idea/.idea.UnityProject/.idea/workspace.xml
@@ -2,13 +2,12 @@
+
+
-
-
-
-
+
@@ -36,9 +35,11 @@
+
+
@@ -67,6 +68,7 @@
+
@@ -120,8 +122,6 @@
@@ -255,6 +257,7 @@
+
1562485186899
diff --git a/UnityProject/Assembly-CSharp.csproj b/UnityProject/Assembly-CSharp.csproj
index 285f158..06f0077 100644
--- a/UnityProject/Assembly-CSharp.csproj
+++ b/UnityProject/Assembly-CSharp.csproj
@@ -99,6 +99,7 @@
+
diff --git a/UnityProject/Assets/Scenes/Examples/Qlist/Qlist.unity b/UnityProject/Assets/Scenes/Examples/Qlist/Qlist.unity
index d56c022..0438222 100644
--- a/UnityProject/Assets/Scenes/Examples/Qlist/Qlist.unity
+++ b/UnityProject/Assets/Scenes/Examples/Qlist/Qlist.unity
@@ -433,6 +433,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
playableDirector: {fileID: 1549059515}
stateManager: {fileID: 1788337936}
+ initTransitionFactor: 10
--- !u!320 &1549059515
PlayableDirector:
m_ObjectHideFlags: 0
@@ -445,7 +446,7 @@ PlayableDirector:
m_PlayableAsset: {fileID: 11400000, guid: dd88d8a2bd5beda41a4bc9a6e2f2d080, type: 2}
m_InitialState: 0
m_WrapMode: 0
- m_DirectorUpdateMode: 1
+ m_DirectorUpdateMode: 3
m_InitialTime: 0
m_SceneBindings:
- key: {fileID: -2136880647211988772, guid: dd88d8a2bd5beda41a4bc9a6e2f2d080, type: 2}
diff --git a/UnityProject/Assets/Scenes/Examples/Qlist/animations/Transitions.playable b/UnityProject/Assets/Scenes/Examples/Qlist/animations/Transitions.playable
index 586884c..672c2d6 100644
--- a/UnityProject/Assets/Scenes/Examples/Qlist/animations/Transitions.playable
+++ b/UnityProject/Assets/Scenes/Examples/Qlist/animations/Transitions.playable
@@ -124,7 +124,7 @@ MonoBehaviour:
m_PostExtrapolationMode: 0
m_PreExtrapolationMode: 1
m_PostExtrapolationTime: Infinity
- m_PreExtrapolationTime: 1
+ m_PreExtrapolationTime: 0
m_DisplayName: BlueToRed
- m_Version: 1
m_Start: 2
@@ -154,7 +154,7 @@ MonoBehaviour:
m_ExposedParameterNames: []
m_AnimationCurves: {fileID: 0}
m_Recordable: 0
- m_PostExtrapolationMode: 0
+ m_PostExtrapolationMode: 1
m_PreExtrapolationMode: 1
m_PostExtrapolationTime: 1
m_PreExtrapolationTime: 2
diff --git a/UnityProject/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs b/UnityProject/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs
index db42434..c835f44 100644
--- a/UnityProject/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs
+++ b/UnityProject/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs
@@ -5,7 +5,7 @@ using UnityEngine.Playables;
namespace cylvester
{
- public class TimelineController : MonoBehaviour, INotificationReceiver
+ public class TimelineController : MonoBehaviour
{
[SerializeField] private PlayableDirector playableDirector;
[SerializeField] private StateManager stateManager;
@@ -13,51 +13,64 @@ namespace cylvester
[SerializeField] private float initTransitionFactor = 1f;
private IList qlistMarkers_;
+ private Boundary boundary_;
+ private float speed_;
public void Start()
{
var timeline = (TimelineAsset)playableDirector.playableAsset;
- var markerTrack = timeline.markerTrack;
- var markers = markerTrack.GetMarkers();
+ var markers = timeline.markerTrack.GetMarkers();
qlistMarkers_ = new List();
foreach (var marker in markers)
qlistMarkers_.Add((QlistMarker)marker);
- playableDirector.Stop();
playableDirector.time = 0;
- playableDirector.Play();
+ boundary_ = new Boundary(null, null);
+ UpdateSpeed();
}
public void OnStateChanged(IStateReader stateManager)
{
var stateName = stateManager.CurrentState.Title;
- foreach (var qlistMarker in qlistMarkers_)
+ var numMarkers = qlistMarkers_.Count;
+ for (var i = 0; i < numMarkers; ++i)
{
- if (qlistMarker.id != stateName) continue;
-
- //playableDirector.Stop(); //This resets speed to 1, so I had to cut it.
- playableDirector.time = qlistMarker.time;
+ if (qlistMarkers_[i].id != stateName)
+ continue;
+
+ playableDirector.time = qlistMarkers_[i].time;
+ var previousMarkerTime = i > 0 ? (double?) qlistMarkers_[i - 1].time : null;
+ var nextMarkerTime = i < numMarkers - 1 ? (double?) qlistMarkers_[i + 1].time : null;
+ boundary_ = new Boundary(previousMarkerTime, nextMarkerTime);
playableDirector.Play();
break;
}
}
- public void OnNotify(Playable origin, INotification notification, object context)
+ private void Update()
{
- if (!stateManager.NextState.HasValue)
+ if (playableDirector.state == PlayState.Paused)
return;
- var nextState = stateManager.NextState.Value;
- var prevState = stateManager.PreviousState.Value; //ToDO this is the same as nextState???
+ var deltaTime = Time.deltaTime;
+ var expectedTimeIncrement = speed_ * deltaTime;
+ var expectedTimeInTimeline = playableDirector.time + expectedTimeIncrement;
- Debug.Log("next State " + prevState.Title);
- Debug.Log("prev State " + prevState.Title);
-
- if (notification.id == nextState.Title)
- {
- playableDirector.Pause(); // reaches the next state (marker) in timeline
- playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(initTransitionFactor); // Max added this instead of .Stop
+ if (boundary_.IsInside(expectedTimeInTimeline))
+ {
+ playableDirector.time = expectedTimeInTimeline;
+ playableDirector.Evaluate();
}
+ else
+ {
+ playableDirector.Pause();
+ UpdateSpeed();
+ }
+ }
+
+ private void UpdateSpeed()
+ {
+ speed_ = initTransitionFactor;
}
}
}
diff --git a/UnityProject/Assets/Scripts/PdConnection/Boundary.cs b/UnityProject/Assets/Scripts/PdConnection/Boundary.cs
new file mode 100644
index 0000000..52ed66d
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/Boundary.cs
@@ -0,0 +1,30 @@
+namespace cylvester
+{
+ public class Boundary
+ {
+ private readonly double? min_;
+ private readonly double? max_;
+
+ public Boundary(double? min, double? max)
+ {
+ min_ = min;
+ max_ = max;
+ }
+
+ public bool IsInside(double value)
+ {
+ if (min_.HasValue)
+ {
+ if (value < min_.Value)
+ return false;
+ }
+ if (max_.HasValue)
+ {
+ if (value > max_.Value)
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Scripts/PdConnection/Boundary.cs.meta b/UnityProject/Assets/Scripts/PdConnection/Boundary.cs.meta
new file mode 100644
index 0000000..903df31
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/Boundary.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: e2af2d984d364c6f87b65a1293490a58
+timeCreated: 1575735381
\ No newline at end of file