public void Play( float startTime, float endTime, WrapMode wrapMode = WrapMode.Once, System.Action callback = null, PlayingDirection playDirection = PlayingDirection.Forwards ) { if (startTime > endTime && playDirection != PlayingDirection.Backwards) { Debug.LogError("End Time must be greater than Start Time.", gameObject); return; } if (isPaused) //if it's paused resume. { Debug.LogWarning("Play called on a Paused cutscene. Cutscene will now resume instead.", gameObject); playingDirection = playDirection; Resume(); return; } if (isActive) { Debug.LogWarning("Cutscene is already Running.", gameObject); return; } playTimeMin = 0; //for mathf.clamp setter playTimeMax = endTime; playTimeMin = startTime; currentTime = startTime; playingWrapMode = wrapMode; playingDirection = playDirection; if (playDirection == PlayingDirection.Forwards) { if (currentTime >= playTimeMax) { currentTime = playTimeMin; } } if (playDirection == PlayingDirection.Backwards) { if (currentTime <= playTimeMin) { currentTime = playTimeMax; } } isActive = true; isPaused = false; OnStop = callback != null ? callback : OnStop; Sample(); //immediately do a preliminary sample first at wherever the currentTime currently is at. SendGlobalMessage("OnCutsceneStarted", this); if (OnCutsceneStarted != null) { OnCutsceneStarted(this); } }
public void Play ( float startTime, float endTime, WrapMode wrapMode = WrapMode.Once, System.Action callback = null, PlayingDirection playDirection = PlayingDirection.Forwards ) { if (startTime > endTime && playDirection != PlayingDirection.Backwards) { Debug.LogError("End Time must be greater than Start Time.", gameObject); return; } if (isPaused) //if it's paused resume. { Debug.LogWarning("Play called on a Paused cutscene. Cutscene will now resume instead.", gameObject); playingDirection = playDirection; Resume(); return; } if (isActive) { Debug.LogWarning("Cutscene is already Running.", gameObject); return; } playTimeStart = 0; //for mathf.clamp setter playTimeEnd = endTime; playTimeStart = startTime; currentTime = startTime; playingWrapMode = wrapMode; playingDirection = playDirection; if (playDirection == PlayingDirection.Forwards) { if (currentTime >= playTimeEnd) { currentTime = playTimeStart; } } if (playDirection == PlayingDirection.Backwards) { if (currentTime <= playTimeStart) { currentTime = playTimeEnd; } } isActive = true; isPaused = false; OnStop = callback != null? callback : OnStop; //SendGlobalMessage("OnCutsceneStarted", this); if (OnCutsceneStarted != null) { OnCutsceneStarted(this); } StartCoroutine(Internal_UpdateCutscene()); }