public void DrawMajorTicks(Rect position, float frameRate)
        {
            Color color = Handles.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
                return;
            }

            TimeArea.InitStyles();
            this.SetTickMarkerRanges();
            this.hTicks.SetTickStrengths(3f, 80f, true);
            Color textColor = TimeArea.styles.TimelineTick.normal.textColor;

            textColor.a   = 0.1f;
            Handles.color = textColor;
            for (int i = 0; i < this.hTicks.tickLevels; i++)
            {
                float num = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
                if (num > 0.5f)
                {
                    float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                    for (int j = 0; j < ticksAtLevel.Length; j++)
                    {
                        if (ticksAtLevel[j] >= 0f)
                        {
                            int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                            float x    = this.FrameToPixel((float)num2, frameRate, position);
                            Handles.DrawLine(new Vector3(x, 0f, 0f), new Vector3(x, position.height, 0f));
                        }
                    }
                }
            }

            GUI.EndGroup();
            Handles.color = color;
        }
Ejemplo n.º 2
0
        public void TimeRuler(Rect position, float frameRate)
        {
            Color color = GUI.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
                return;
            }
            TimeArea.InitStyles();
            HandlesExtra.ApplyWireMaterial();
            GL.Begin(1);
            Color backgroundColor = GUI.backgroundColor;

            this.SetTickMarkerRanges();
            this.hTicks.SetTickStrengths(3f, 80f, true);
            Color textColor = TimeArea.styles.TimelineTick.normal.textColor;

            textColor.a = 0.75f;
            for (int i = 0; i < this.hTicks.tickLevels; i++)
            {
                float   num          = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
                float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                for (int j = 0; j < ticksAtLevel.Length; j++)
                {
                    if (ticksAtLevel[j] >= base.hRangeMin && ticksAtLevel[j] <= base.hRangeMax)
                    {
                        int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                        float num3 = position.height * Mathf.Min(1f, num) * 0.7f;
                        float num4 = this.FrameToPixel((float)num2, frameRate, position);
                        GL.Color(new Color(1f, 1f, 1f, num / 0.5f) * textColor);
                        GL.Vertex(new Vector3(num4, position.height - num3 + 0.5f, 0f));
                        GL.Vertex(new Vector3(num4, position.height - 0.5f, 0f));
                        if (num > 0.5f)
                        {
                            GL.Color(new Color(1f, 1f, 1f, num / 0.5f - 1f) * textColor);
                            GL.Vertex(new Vector3(num4 + 1f, position.height - num3 + 0.5f, 0f));
                            GL.Vertex(new Vector3(num4 + 1f, position.height - 0.5f, 0f));
                        }
                    }
                }
            }
            GL.End();
            int levelWithMinSeparation = this.hTicks.GetLevelWithMinSeparation(40f);

            float[] ticksAtLevel2 = this.hTicks.GetTicksAtLevel(levelWithMinSeparation, false);
            for (int k = 0; k < ticksAtLevel2.Length; k++)
            {
                if (ticksAtLevel2[k] >= base.hRangeMin && ticksAtLevel2[k] <= base.hRangeMax)
                {
                    int    num5 = Mathf.RoundToInt(ticksAtLevel2[k] * frameRate);
                    float  num6 = Mathf.Floor(this.FrameToPixel((float)num5, frameRate, base.rect));
                    string text = this.FormatFrame(num5, frameRate);
                    GUI.Label(new Rect(num6 + 3f, -3f, 40f, 20f), text, TimeArea.styles.TimelineTick);
                }
            }
            GUI.EndGroup();
            GUI.backgroundColor = backgroundColor;
            GUI.color           = color;
        }