Skip to content

Instantly share code, notes, and snippets.

@dilmerv dilmerv/SaveCheckPointFPS.cs Secret
Created Nov 17, 2015

Embed
What would you like to do?
void OnTriggerEnter2D(Collider2D col){
if(Globals.playIsDoing == Globals.PlayerIsDoing.Idle)
return;
if(col.WithPlayer() && !activated){
Time.captureFramerate = saveScreenshotFrameRate;
instance = this;
instance.SetSaveUnitData();
instance.activated = true;
StartCoroutine(instance.SaveCheckPoint());
StartCoroutine(instance.TakeScreenshot());
}
}
IEnumerator SaveCheckPoint(){
yield return null;
SerializerUtils.SaveCheckPointAsJSON(instance.data, persistentPath, Globals.currentLevel, number);
instance.number = number;
instance.LoadCheckPoint(Globals.currentLevel,number);
}
IEnumerator TakeScreenshot(){
//Save Screenshot of the Level
var directory = Path.Combine (persistentPath, "CheckPoint");
var destination = Path.Combine(directory,string.Format("Level_{0}_{1}.png",
Globals.currentLevel,number));
Application.CaptureScreenshot(destination, 1);
yield return new WaitForSeconds(0.3f);
Time.captureFramerate = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.