public FadeArea BeginFadeArea(bool open, string label, string id, GUIStyle areaStyle, GUIStyle labelStyle)
        {
            //Rect r = EditorGUILayout.BeginVertical (areaStyle);

            Color tmp1 = GUI.color;

            FadeArea fadeArea = BeginFadeArea(open, id, 20, areaStyle);
            //GUI.Box (r,"",areaStyle);

            Color tmp2 = GUI.color;

            GUI.color = tmp1;

            if (label != "")
            {
                if (GUILayout.Button(label, labelStyle))
                {
                    fadeArea.open = !fadeArea.open;
                    editor.Repaint();
                }
            }

            GUI.color = tmp2;

            //EditorGUILayout.EndVertical ();
            return(fadeArea);
        }
        public void EndFadeArea()
        {
            if (stack.Count <= 0)
            {
                Debug.LogError("You are popping more Fade Areas than you are pushing, make sure they are balanced");
                return;
            }

            FadeArea fadeArea = stack.Pop();

            //Debug.Log (r);
            //fadeArea.tmp = r;

            //r.width = 10;
            //r.height = 10;
            //GUI.Box (r,"");
            //GUILayout.Label ("HEllo : ");
            EditorGUILayout.EndVertical();
            GUILayout.EndArea();

            if (fade)
            {
                GUI.color = fadeArea.preFadeColor;
            }
            //GUILayout.Label ("Outside");

            /*currentDepth--;
             *
             * Rect r = GUILayoutUtility.GetRect (new GUIContent (),stretchStyle,GUILayout.Height (0));
             *
             * if (Event.current.type == EventType.Repaint || Event.current.type == EventType.ScrollWheel) {
             *      Rect currentRect = currentRects[id];
             *      Rect newRect = new Rect (currentRect.x,currentRect.y,currentRect.width,r.y-minHeight);
             *
             *      currentRects[id] = newRect;
             *
             *      if (lastRects[id] != newRect) {
             *              changedDelta = true;
             *              lastUpdate = Time.realtimeSinceStartup;
             *              editor.Repaint ();
             *      }
             *
             * }
             *
             * GUILayout.EndArea ();*/
        }
Пример #3
0
        public void EndFadeArea()
        {
            if (fadeAreaStack.Count <= 0)
            {
                Debug.LogError("You are popping more Fade Areas than you are pushing, make sure they are balanced");
                return;
            }

            FadeArea fadeArea = fadeAreaStack.Pop();

            EditorGUILayout.EndVertical();
            GUILayout.EndArea();

            if (fade)
            {
                GUI.color = fadeArea.preFadeColor;
            }
        }
Пример #4
0
        public FadeArea BeginFadeArea(bool open, string label, string id, GUIStyle areaStyle, GUIStyle labelStyle)
        {
            Color tmp1 = GUI.color;

            FadeArea fadeArea = BeginFadeArea(open, id, 20, areaStyle);

            Color tmp2 = GUI.color;

            GUI.color = tmp1;

            if (label != "")
            {
                if (GUILayout.Button(label, labelStyle))
                {
                    fadeArea.open = !fadeArea.open;
                    editor.Repaint();
                }
            }

            GUI.color = tmp2;

            return(fadeArea);
        }
Пример #5
0
        public FadeArea BeginFadeArea(bool open, string id, float minHeight, GUIStyle areaStyle)
        {
            if (editor == null)
            {
                Debug.LogError("You need to set the 'EditorGUIx.editor' variable before calling this function");
                return(null);
            }

            if (fadeAreaStack == null)
            {
                fadeAreaStack = new Stack <FadeArea>();
            }

            if (fadeAreas == null)
            {
                fadeAreas = new Dictionary <string, FadeArea>();
            }

            FadeArea fadeArea;

            if (!fadeAreas.TryGetValue(id, out fadeArea))
            {
                fadeArea = new FadeArea(open);
                fadeAreas.Add(id, fadeArea);
            }

            fadeAreaStack.Push(fadeArea);

            fadeArea.open = open;

            // Make sure the area fills the full width
            areaStyle.stretchWidth = true;

            Rect lastRect = fadeArea.lastRect;

            if (!fancyEffects)
            {
                fadeArea.value   = open ? 1F : 0F;
                lastRect.height -= minHeight;
                lastRect.height  = open ? lastRect.height : 0;
                lastRect.height += minHeight;
            }
            else
            {
                lastRect.height  = lastRect.height < minHeight ? minHeight : lastRect.height;
                lastRect.height -= minHeight;
                float faded = Hermite(0F, 1F, fadeArea.value);
                lastRect.height *= faded;
                lastRect.height += minHeight;
                lastRect.height  = Mathf.Round(lastRect.height);
            }

            Rect gotLastRect = GUILayoutUtility.GetRect(new GUIContent(), areaStyle, GUILayout.Height(lastRect.height));

            //The clipping area, also drawing background
            GUILayout.BeginArea(lastRect, areaStyle);

            Rect newRect = EditorGUILayout.BeginVertical();

            if (Event.current.type == EventType.Repaint || Event.current.type == EventType.ScrollWheel)
            {
                newRect.x            = gotLastRect.x;
                newRect.y            = gotLastRect.y;
                newRect.width        = gotLastRect.width;
                newRect.height      += areaStyle.padding.top + areaStyle.padding.bottom;
                fadeArea.currentRect = newRect;

                if (fadeArea.lastRect != newRect)
                {
                    //@Fix - duplicate
                    //fadeArea.lastUpdate = Time.realtimeSinceStartup;
                    editor.Repaint();
                }

                fadeArea.Switch();
            }

            if (Event.current.type == EventType.Repaint)
            {
                float value       = fadeArea.value;
                float targetValue = open ? 1F : 0F;

                float newRectHeight = fadeArea.lastRect.height;
                float deltaHeight   = 400F / newRectHeight;

                float deltaTime = Mathf.Clamp(Time.realtimeSinceStartup - fadeAreas[id].lastUpdate, 0.00001F, 0.05F);

                deltaTime *= Mathf.Lerp(deltaHeight * deltaHeight * 0.01F, 0.8F, 0.9F);

                fadeAreas[id].lastUpdate = Time.realtimeSinceStartup;


                if (Mathf.Abs(targetValue - value) > 0.001F)
                {
                    float time = Mathf.Clamp01(deltaTime * speed);
                    value += time * Mathf.Sign(targetValue - value);
                    editor.Repaint();
                }
                else
                {
                    value = Mathf.Round(value);
                }

                fadeArea.value = Mathf.Clamp01(value);
            }

            if (fade)
            {
                Color c = GUI.color;
                fadeArea.preFadeColor = c;
                c.a      *= fadeArea.value;
                GUI.color = c;
            }

            fadeArea.open = open;

            return(fadeArea);
        }