Ejemplo n.º 1
0
        // Change params to hrangelocked and vrangelocked
        // protected void InitTimeArea()
        protected void InitTimeArea(
            bool hLocked     = false,
            bool vLocked     = true,
            bool showhSlider = false,
            bool showVSlider = false)
        {
            if (_simpleTimeArea == null)
            {
                // create new timeArea
                this._simpleTimeArea = new TimeArea(false)
                {
                    hRangeLocked    = hLocked,
                    vRangeLocked    = vLocked,
                    margin          = 10f,
                    scaleWithWindow = true,
                    hSlider         = showhSlider,
                    vSlider         = showVSlider,
                    hRangeMin       = 0f,
                    vRangeMin       = float.NegativeInfinity,
                    vRangeMax       = float.PositiveInfinity,
                    mRect           = _timeAreaBounds,
                };
                this._simpleTimeArea.hTicks.SetTickModulosForFrameRate(this._frameRate);
                // show time range begin seconds to end seconds(xxs - xxs)
                this._simpleTimeArea.SetShownHRange(-1, 5f);
                this._simpleTimeArea.SetShownVRange(0, 100f);

                Debug.Log("------>## Init Simple Time Area ##");
            }
        }
Ejemplo n.º 2
0
 public static void DrawVerticalLine(float x, float minY, float maxY, Color color)
 {
     if (Event.current.type == EventType.Repaint)
     {
         // HandleUtility.ApplyWireMaterial();
         TimeAreaTools.ReflectionApplyWireMaterial();
         if (Application.platform == RuntimePlatform.WindowsEditor)
         {
             GL.Begin(7);
         }
         else
         {
             GL.Begin(1);
         }
         TimeArea.DrawVerticalLineFast(x, minY, maxY, color);
         GL.End();
     }
 }
Ejemplo n.º 3
0
        public void DrawMajorTicks(Rect position, float frameRate)
        {
            Color color = Handles.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
            }
            else
            {
                TimeArea.InitStyles();
                this.SetTickMarkerRanges();
                this.hTicks.SetTickStrengths(3f, 80f, true);
                Color textColor = TimeArea.styles.TimelineTick.normal.textColor;
                textColor.a   = 0.1f;
                Handles.color = textColor;
                Rect shownArea = base.shownArea;
                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, shownArea);
                                Handles.DrawLine(new Vector3(x, 0f, 0f), new Vector3(x, position.height, 0f));
                            }
                        }
                    }
                }
                GUI.EndGroup();
                Handles.color = color;
            }
        }
Ejemplo n.º 4
0
        public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha, TimeArea.TimeFormat timeFormat)
        {
            Color color = GUI.color;

            GUI.BeginGroup(position);
            TimeArea.InitStyles();
            // HandleUtility.ApplyWireMaterial();
            TimeAreaTools.ReflectionApplyWireMaterial();
            Color backgroundColor = GUI.backgroundColor;

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

            textColor.a = 0.75f * alpha;
            if (Event.current.type == EventType.Repaint)
            {
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    GL.Begin(7);
                }
                else
                {
                    GL.Begin(1);
                }
                // Rect shownArea = base.shownArea;
                float a     = ShowAreaXMin * frameRate * position.width;
                float b     = ShowAreaWidth * frameRate;
                float width = position.width;

                float horRangeMax = base.hRangeMax;
                float horRangeMin = base.hRangeMin;

                for (int i = 0; i < this.hTicks.tickLevels; i++)
                {
                    float   num          = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
                    Color   c1           = new Color(1f, 1f, 1f, num / 0.5f) * textColor;
                    float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                    for (int j = 0; j < ticksAtLevel.Length; j++)
                    {
                        if (ticksAtLevel[j] >= horRangeMin && ticksAtLevel[j] <= horRangeMax)
                        {
                            int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                            float num3 = (!useEntireHeight) ? (position.height * Mathf.Min(1f, num) * 0.7f) : position.height;
                            // float x = this.FrameToPixel((float)num2, frameRate, position, shownArea);
                            float x = this.FrameToPixelForTimeRuler((float)num2, width, a, b);
                            TimeArea.DrawVerticalLineFast(x, position.height - num3 + 0.5f, position.height - 0.5f, c1);
                        }
                    }
                }
                GL.End();
            }
            if (labels)
            {
                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    num4 = Mathf.RoundToInt(ticksAtLevel2[k] * frameRate);
                        float  num5 = Mathf.Floor(this.FrameToPixel((float)num4, frameRate, position));
                        string text = this.FormatTime(ticksAtLevel2[k], frameRate, timeFormat);
                        GUI.Label(new Rect(num5 + 3f, -3f, 40f, 20f), text, TimeArea.styles.TimelineTick);
                    }
                }
            }
            GUI.EndGroup();
            GUI.backgroundColor = backgroundColor;
            GUI.color           = color;
        }