예제 #1
0
    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();
        }
    }
예제 #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();
        }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
    private void StartFading(FadeDelegate callback, float targetPoint)
    {
        if (m_FadeRoutine != null)
        {
            StopCoroutine(m_FadeRoutine);
        }

        m_FadeRoutine = StartCoroutine(FadeRoutine(callback, targetPoint));
    }
예제 #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();
 }
예제 #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();
 }
예제 #8
0
파일: Fader.cs 프로젝트: fsproru/fader
    /// <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;
    }
예제 #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();
 }
예제 #10
0
 public void FadeGroup(string title, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, true, UnityEditor.EditorStyles.helpBox, fadeFunc);
 }
예제 #11
0
 public void FadeIn(FadeDelegate callback)
 {
     StartFading(callback, 1.0f);
 }
예제 #12
0
 public void ToggleGroup(string title, bool autoOpen, FadeDelegate fadeFunc)
 {
     ToggleGroup(title, title, autoOpen, fadeFunc);
 }
예제 #13
0
 public void ToggleGroup(string title, FadeDelegate fadeFunc)
 {
     ToggleGroup(title, title, true, fadeFunc);
 }
예제 #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);
        }
예제 #15
0
 public void FadeGroup(string title, bool autoOpen, GUIStyle style, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, autoOpen, style, fadeFunc);
 }
예제 #16
0
 public void FadeGroup(string title, GUIStyle style, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, true, style, fadeFunc);
 }
예제 #17
0
 public void FadeGroup(string title, bool autoOpen, FadeDelegate fadeFunc)
 {
     FadeGroup(title, title, autoOpen, UnityEditor.EditorStyles.helpBox, fadeFunc);
 }
예제 #18
0
 public void FadeOut(FadeDelegate callback)
 {
     StartFading(callback, 0.0f);
 }
예제 #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;
 }
예제 #21
0
 public void SetFadeInCallback(FadeDelegate callback)
 {
     _fadeInCallback = callback;
 }