# 20241016. 新增 ScreenTransition

增加了三个比较常用的屏幕过渡：FadeIn，FadeOut，FadeInOut。

示例代码如下:

```csharp
using UnityEngine;

namespace QFramework.Example
{
    public class ScreenTransitionsExample : MonoBehaviour
    {
        private void OnGUI()
        {
            IMGUIHelper.SetDesignResolution(640,360);
            
            if (GUILayout.Button("FadeIn"))
            {
                ActionKit.ScreenTransition
                    .FadeIn()
                    .Start(this);
            }
            
            if (GUILayout.Button("FadeOut"))
            {
                ActionKit.ScreenTransition
                    .FadeOut()
                    .Start(this);
            }
            
            if (GUILayout.Button("FadeInOut"))
            {
                ActionKit.ScreenTransition
                    .FadeInOut()
                    .OnInFinish(() =>
                    {
                        Debug.Log("load scene here");
                    })
                    .Start(this);
            }
            
            if (GUILayout.Button("FadeIn White"))
            {
                ActionKit.ScreenTransition
                    .FadeIn()
                    .Color(Color.white)
                    .Start(this);
            }
            
            if (GUILayout.Button("FadeOut Red"))
            {
                ActionKit.ScreenTransition
                    .FadeOut()
                    .Color(Color.red)
                    .Start(this);
            }
            
            if (GUILayout.Button("FadeInOut 0.5s in green out blue"))
            {
                ActionKit.ScreenTransition
                    .FadeInOut()
                    .In(fadeIn=>fadeIn
                        .Duration(0.5f)
                        .Color(Color.green))
                    .Out(fadeOut=>fadeOut.Duration(0.5f)
                        .Color(Color.blue))
                    .Start(this);
            }
        }
    }
}

```

运行后结果如下:

![screen_transition](https://file.liangxiegame.com/15c9c162-6622-4190-850b-ed0547441973.gif)

本文由 QFramework 教程年会员赞助，地址：[https://www.gamepixedu.com/goods/show/55](https://www.gamepixedu.com/goods/show/55)

* QFramework 主页：[qframework.cn](https://qframework.cn)
* QFramework 交流群: 541745166
* QFramework Github 地址: <https://github.com/liangxiegame/qframework>
* QFramework Gitee 地址：<https://gitee.com/liangxiegame/QFramework>