Example #1
0
    private void _StopEffect(EPostEffectType type)
    {
        var comp = GetOrCreateEffect(type);

        if (comp == null)
        {
            return;
        }

        comp.enabled = false;
        comp.StopEffect();
    }
Example #2
0
    private void _StartEffect(EPostEffectType type, float duration = 0.1f, float fadeInTime = 0,
                              float fadeOutTime = 0, object param = null)
    {
        var comp = GetOrCreateEffect(type);

        if (comp == null)
        {
            return;
        }

        comp.enabled = true;
        comp.StartEffect(duration, fadeInTime, fadeOutTime, param);
    }
Example #3
0
    public IPostEffect GetOrCreateEffect(EPostEffectType type)
    {
        var idx = (int)type;

        if (idx < 0 || idx >= MAX_EFFECT_COUNT)
        {
            Debug.LogError("EPostEffectType out of range" + type.ToString());
            return(null);
        }

        IPostEffect comp = null;

        if (_allEffects[idx] == null)
        {
            switch (type)
            {
            case EPostEffectType.RadialBlur:
                comp = _mainCamera.GetOrAddComponent <PostEffectRadialBlur>();
                break;

            default:
                break;
            }

            comp.OnInstance();
            if (comp.shader == null)
            {
                Debug.LogError("Can not find PostEffect shader " + type.ToString());
                return(null);
            }

            _allEffects[idx] = comp;
        }

        return(_allEffects[idx]);
    }
Example #4
0
 public static void StopEffect(EPostEffectType type)
 {
     Instance?._StopEffect(type);
 }
Example #5
0
 public static void StartEffect(EPostEffectType type, float duration = 0.1f, float fadeInTime = 0,
                                float fadeOutTime = 0, object param = null)
 {
     Instance?._StartEffect(type, duration, fadeInTime, fadeOutTime, param);
 }