void worker_DoWork(object sender, DoWorkEventArgs e) { Thread.Sleep(2000); opacDel = delegate() { this.ShowInTaskbar = true; }; try { this.Invoke(opacDel); } catch { } Thread.Sleep(1000); opacDel = delegate() { this.Opacity = 100; Cursor.Current = Cursors.Default; splashThread.Abort(); }; try { this.Invoke(opacDel); } catch { } }
public static IEnumerator DoFadeOpacity(OpacityDelegate opacityDelegate, float fromOpacity, float toOpacity, float fadeDuration) { float currentTime = 0f; while (currentTime <= fadeDuration) { float timeProportion = currentTime / fadeDuration; opacityDelegate(fromOpacity + (toOpacity - fromOpacity) * timeProportion); currentTime += Time.timeScale == 0f ? Time.fixedUnscaledDeltaTime : Time.fixedDeltaTime; yield return(null); } opacityDelegate(toOpacity); }