private void OnDisable() { if (_encoder == null) { return; } _encoder.Reset(); _encoder = null; }
private void OnDisable() { _rawFrames.Clear(); _insertFrames.Clear(); // insertFrames.ForEach(Destroy); #if !UNITY_EDITOR insertFrames.ForEach(DestroyImmediate); #endif insertFrames.Clear(); if (_encoder == null) { return; } _encoder.Reset(); _encoder = null; }
public IObservable <string> GetGifAsFile(string filePath, bool debug = false) { if (_rawFrames.Count != 0) { return(Observable.Start(() => { var gifFrames = ReorderFrames(_rawFrames); var qVal = (float)quality; var q = Mathf.RoundToInt(qVal.FromTo(1, 100, 30, 1)); _encoder = new RGifEncoder(repeat ? 0 : -1, q, gifFrames, targetFps, chunkSize, width, height); return RGifEncoder.SaveToFile(_encoder.GetGifStream(debug), filePath) .DoOnTerminate(() => _encoder.Reset()) .DoOnError(err => { Debug.Log(err); _encoder.Reset(); }).DoOnCancel(() => _encoder.Reset()) .DoOnCompleted(() => _encoder.Reset()); }, Scheduler.ThreadPool).Merge()); } Debug.LogError("cannot process if frame count 0"); throw new Exception("cannot process if frame count 0"); }