Here is a quick and easy fix to all cinematics “Played State” not resetting every time you go to a diferent scene
Step 1
- Add the “SaveableEntity.cs” to your Intro Sequence (or other cinematics you have)
Step 2
- In your “CinematicTrigger.cs” add the ISavalbe interface and create the 2 methods like this
namespace RPG.Cinematics
{
public class CinematicTrigger : MonoBehaviour, ISaveable
{
private bool wasPlayed = false;
private void OnTriggerEnter(Collider other)
{
if (!wasPlayed && other.gameObject.CompareTag("Player"))
{
wasPlayed = true;
GetComponent<PlayableDirector>().Play();
}
}
public object CaptureState()
{
Dictionary<string, object> data = new Dictionary<string, object>();
data["Cinematic"] = wasPlayed;
return data;
}
public void RestoreState(object state)
{
Dictionary<string, object> data = (Dictionary<string, object>)state;
wasPlayed = (bool)data["Cinematic"];
Debug.Log("Restored "+wasPlayed);
}
}
}