Hi!
There is a problem that has been bothering me for a long time. I try to use an int parameter to control the playback of cutscenes. After writing the ISaveable interface, no matter how I modify it, I cannot save this parameter. Please help, thanks!
using UnityEngine;
using UnityEngine.Playables;
using RPG.Saving;
namespace RPG.Cinematics
{
public class IntroCinematic : MonoBehaviour, ISaveable
{
int triggerIndex;
private void Start()
{
triggerIndex = 0;
}
private void Update()
{
if(triggerIndex == 1)
{
GetComponent<BoxCollider>().enabled = false;
}
print(triggerIndex);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
GetComponent<PlayableDirector>().Play();
GetComponent<BoxCollider>().enabled = false;
triggerIndex = 1;
}
}
object ISaveable.CaptureState()
{
return triggerIndex;
}
void ISaveable.RestoreState(object state)
{
triggerIndex = (int)state;
}
}
}