Skip to content

gok11/UniFader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniFader GitHub license

UniFader is a transition helper components for Unity.

Supported Unity versions

Unity 2019.3 or higher.

Quick Start

  1. Download UniFader.unitypackage from releases page and import it.
  2. You can transition scene by calling only UniFader.Instance.LoadSceneWithFade(0).
  3. Enjoy!

ColorFade

Samples can be seen in Sample folder if you want.

Description

You can use two transition types - Color Fade and Gradient Mask Fade.

Fade Pattern Feature Screenshot
Color Fade Simple color fade effect. You can set base color from Background Color. ColorFade
Gradient Mask Fade Transition with gradient gray scaled texture. GradientMaskFade

Usage for Mask Gradient Fade

  1. Download UniFader.unitypackage from releases page and import it.

  2. Create new GameObject and add UniFader component from Add Component in inspector.

  3. Change Fade Pattern to MaskGradientFade
    ChangeToMGF

  4. Set Transition Material from Assets/UniFader/Materials/UI_GradientMaskTransition.mat.

  5. Set Mask Texture from and Assets/UniFader/Sample/Textures/SampleGradientMasks.
    SetElements

  6. Play!

Transition options

Easing

Edit easing from Fade Out Curve and Fade In Curve.

Fade Out In Mode (Gradient Mask Fade only)

Yoyo
Invert Yoyo
Repeat twice
Repeat invert twice

FadePatterns

Tips

Used As Instance

If this is enabled, the fader will be singleton instance. It is referenced from UniFader.Instance and it will be set DontDestroyOnLoad.

Add fade pattern

You can add Fade Pattern by implementing IFadePattern.

using MB.UniFader;
using UnityEngine;
using UnityEngine.UI;

public class TestFade : IFadePattern
{
    [SerializeField] private int hoge;
    [SerializeField] private Color fuga;

    public void Initialize(Image targetImage) { }

    public void ExecFade(float progress, bool fadeOut) { }
}

After that, you can select that pattern in Fade Pattern in inspector.

AddPattern

Add callback

You can add callback from inspector (On Fade Out / In) or script. If you add callback for FadeOut, you can write as follows.

using System.Collections;
using UnityEngine;
using MB.UniFader;

public class FadeTest : MonoBehaviour
{
    void Start()
    {
        UniFader.Instance.FadeOut(() =>
        {
            Debug.Log("FadeOut completed!");
        });
    }
}

License

  • MIT
  • © UTJ/UCL

Author

Gok