Ben did a solution for thefirst challenge whereby the ReplaySystem grabs the GameManager and asks “Should I be recording or playing?”. However I did it the other way around where the GameManager tells the replaysystem what to do based on teh recording, with this code in the GameManager. The boolean isn’t really directly needed in my version as the button is readily available but could easily be adjusted with a “IsRecording” property. But I’m guessing there’s pros and cons of both approaches. I prefer Ben’s version in hindsight because it leaves the traversing of the ReplaySystems to the Unity framework rather than in script. However in more complicated scenarios like if you were filming from object to object during the replay it could be handy to have the Replay objects available in a list.
void Start() {
replaySystems = GameObject.FindObjectsOfType<ReplaySystem> ();
}
void Update () {
bool result = CrossPlatformInputManager.GetButton ("Fire1");
if (result) {
recording = false;
foreach(ReplaySystem replay in replaySystems )
replay.PlayBack ();
} else {
recording = true;
foreach(ReplaySystem replay in replaySystems )
replay.Record ();
}
}