private IEnumerator FadeRoutine(FadeDelegate callback, float targetPoint)
    {
        while (m_CurrentPoint != targetPoint)
        {
            float prevSign = Mathf.Sign(targetPoint - m_CurrentPoint);

            //Change the color
            m_CurrentPoint += prevSign * m_Speed * Time.fixedDeltaTime; //Ignores deltaTime

            float afterSign = Mathf.Sign(targetPoint - m_CurrentPoint);

            //We flipped
            if (prevSign != afterSign)
            {
                m_CurrentPoint = targetPoint;
            }

            SetColor(m_CurrentPoint);
            yield return(new WaitForEndOfFrame());
        }

        m_FadeRoutine = null;

        if (callback != null)
        {
            callback();
        }
    }
Exemple #2
0
        public static void FadeGroup(string title, ref bool fade, FadeDelegate preTitle, FadeDelegate postTitle, FadeDelegate fadeFunc)
        {
            float minw, maxw;

            UnityEditor.EditorGUILayout.BeginVertical(UnityEditor.EditorStyles.helpBox);
            UnityEditor.EditorGUILayout.BeginHorizontal();
            fade = UnityEditor.EditorGUILayout.Toggle(fade, UnityEditor.EditorStyles.foldout, UnityEngine.GUILayout.Width(15));
            if (preTitle != null)
            {
                preTitle();
            }
            UnityEditor.EditorStyles.boldLabel.CalcMinMaxWidth(new GUIContent(title), out minw, out maxw);
            UnityEditor.EditorGUILayout.LabelField(title, UnityEditor.EditorStyles.boldLabel, GUILayout.Width(maxw));
            if (postTitle != null)
            {
                postTitle();
            }
            UnityEditor.EditorGUILayout.EndHorizontal();
            if (UnityEditor.EditorGUILayout.BeginFadeGroup(System.Convert.ToInt32(fade)))
            {
                if (fadeFunc != null)
                {
                    fadeFunc();
                }
            }
            UnityEditor.EditorGUILayout.EndFadeGroup();
            UnityEditor.EditorGUILayout.EndVertical();
        }
Exemple #3
0
        public void ToggleGroup(string title, string id, bool autoOpen, FadeDelegate fadeFunc)
        {
            bool open = TryGetFadeStack(id, autoOpen);

            ExGUI.ToggleGroup(title, ref open, fadeFunc);
            RecordValue(id, open);
        }
Exemple #4
0
        public void FadeGroup(string title, bool autoOpen, FadeDelegate preTitle, FadeDelegate postTitle, FadeDelegate fadeFunc)
        {
            bool open = TryGetFadeStack(title, autoOpen);

            ExGUI.FadeGroup(title, ref open, preTitle, postTitle, fadeFunc);
            RecordValue(title, open);
        }
    private void StartFading(FadeDelegate callback, float targetPoint)
    {
        if (m_FadeRoutine != null)
        {
            StopCoroutine(m_FadeRoutine);
        }

        m_FadeRoutine = StartCoroutine(FadeRoutine(callback, targetPoint));
    }
Exemple #6
0
 public static void ToggleGroup(string title, ref bool toggle, FadeDelegate fadeFunc)
 {
     toggle = UnityEditor.EditorGUILayout.BeginToggleGroup(title, toggle);
     if (fadeFunc != null)
     {
         fadeFunc();
     }
     UnityEditor.EditorGUILayout.EndToggleGroup();
 }
Exemple #7
0
 public static void FadeToggle(string title, ref bool toggle, FadeDelegate fadeFunc)
 {
     UnityEditor.EditorGUILayout.BeginVertical(UnityEditor.EditorStyles.helpBox);
     toggle = UnityEditor.EditorGUILayout.ToggleLeft(title, toggle, UnityEditor.EditorStyles.boldLabel);
     if (fadeFunc != null && toggle)
     {
         fadeFunc();
     }
     UnityEditor.EditorGUILayout.EndVertical();
 }
Exemple #8
0
    /// <summary>
    /// Fade the entire screen based on the direction.
    /// </summary>
    /// <param name="direction">Fade direction.</param>
    /// <param name="fadeDelegate">Delegate to be executed after the fading is done.</param>
    public static void Fade(FadeDirection direction, FadeDelegate fadeDelegate = null)
    {
        var gameObject = new GameObject("Fade");
        var fader      = gameObject.AddComponent <Fader> ();

        fader.gameObject   = gameObject;
        fader.alpha        = direction == FadeDirection.In ? 0.0f : 1.0f;
        fader.texture      = Resources.Load("black") as Texture2D;
        fader.direction    = direction;
        fader.fadeDelegate = fadeDelegate;
    }
Exemple #9
0
 public static void FadeGroup(string title, ref bool fade, GUIStyle style, FadeDelegate fadeFunc)
 {
     UnityEditor.EditorGUILayout.BeginVertical(style);
     UnityEditor.EditorGUILayout.BeginHorizontal();
     fade = UnityEditor.EditorGUILayout.Toggle(fade, UnityEditor.EditorStyles.foldout, UnityEngine.GUILayout.Width(15));
     UnityEditor.EditorGUILayout.LabelField(title, UnityEditor.EditorStyles.boldLabel);
     UnityEditor.EditorGUILayout.EndHorizontal();
     if (UnityEditor.EditorGUILayout.BeginFadeGroup(System.Convert.ToInt32(fade)))
     {
         if (fadeFunc != null)
         {
             fadeFunc();
         }
     }
     UnityEditor.EditorGUILayout.EndFadeGroup();
     UnityEditor.EditorGUILayout.EndVertical();
 }
Exemple #10
0
 public void FadeGroup(string title, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, true, UnityEditor.EditorStyles.helpBox, fadeFunc);
 }
 public void FadeIn(FadeDelegate callback)
 {
     StartFading(callback, 1.0f);
 }
Exemple #12
0
 public void ToggleGroup(string title, bool autoOpen, FadeDelegate fadeFunc)
 {
     ToggleGroup(title, title, autoOpen, fadeFunc);
 }
Exemple #13
0
 public void ToggleGroup(string title, FadeDelegate fadeFunc)
 {
     ToggleGroup(title, title, true, fadeFunc);
 }
Exemple #14
0
        public void FadeGroup(string title, string id, bool autoOpen, GUIStyle style, FadeDelegate fadeFunc)
        {
            bool open = TryGetFadeStack(id, autoOpen);

            ExGUI.ColorGUI(Color.white, delegate
            {
                ExGUI.FadeGroup(title, ref open, style, fadeFunc);
            });
            RecordValue(id, open);
        }
Exemple #15
0
 public void FadeGroup(string title, bool autoOpen, GUIStyle style, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, autoOpen, style, fadeFunc);
 }
Exemple #16
0
 public void FadeGroup(string title, GUIStyle style, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, true, style, fadeFunc);
 }
Exemple #17
0
 public void FadeGroup(string title, bool autoOpen, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, autoOpen, UnityEditor.EditorStyles.helpBox, fadeFunc);
 }
 public void FadeOut(FadeDelegate callback)
 {
     StartFading(callback, 0.0f);
 }
Exemple #19
0
 public static void FadeGroup(string title, ref bool fade, FadeDelegate fadeFunc)
 {
     FadeGroup(title, ref fade, UnityEditor.EditorStyles.helpBox, fadeFunc);
 }
 public void SetFadeOutCallback(FadeDelegate callback)
 {
     _fadeOutCallback = callback;
 }
Exemple #21
0
 public void SetFadeInCallback(FadeDelegate callback)
 {
     _fadeInCallback = callback;
 }