void Snapshot() { snapshots.Add(CaptureTheGIF.Snapshot(width, height)); if (snapshots.Count > frames) { RenderTexture.ReleaseTemporary(snapshots[0]); snapshots.RemoveAt(0); } }
void Awake() { if (instance) { Debug.LogError("there is already an instance of CaptureTheGIF"); Destroy(gameObject); return; } instance = this; }
void Update() { if (Time.time >= lastSnapshot + 1 / frameRate) { lastSnapshot = Time.time; Snapshot(); } if (Input.GetKeyDown(key)) { var file = CaptureTheGIF.MakeFile(dir, name); CaptureTheGIF.Instance.MakeGif(snapshots.ToList(), 1 / frameRate, file, true); snapshots.Clear(); } }