/// <summary>
            /// Rebuilds the editor display using the provided color keys.
            /// </summary>
            /// <param name="keys">Set of keys to initially display on the editor.</param>
            public void Rebuild(List <ColorGradientKey> keys)
            {
                this.keys = keys;

                canvas.Clear();
                for (int i = 0; i < keys.Count; i++)
                {
                    DrawColor(keys[i].color, MathEx.Clamp01(keys[i].time), i == selectedIdx);
                }
            }
        /// <summary>
        /// Rebuilds the internal GUI elements. Should be called whenever timeline properties change.
        /// </summary>
        public void Rebuild()
        {
            canvas.Clear();

            int   heightOffset = height / 2;
            float pixelsPerHeight;

            if (rangeEnd != rangeStart)
            {
                pixelsPerHeight = height / (rangeEnd - rangeStart);
            }
            else
            {
                pixelsPerHeight = 0;
            }

            float yOffset = rangeStart + (rangeEnd - rangeStart) * 0.5f;

            int numTickLevels = tickHandler.NumLevels;

            for (int i = numTickLevels - 1; i >= 0; i--)
            {
                float[] ticks    = tickHandler.GetTicks(i);
                float   strength = tickHandler.GetLevelStrength(i);

                if (ticks.Length > 0)
                {
                    float valuePerTick = (rangeEnd - rangeStart) / ticks.Length;

                    for (int j = 0; j < ticks.Length; j++)
                    {
                        int yPos = (int)((ticks[j] - yOffset) * pixelsPerHeight);
                        yPos = heightOffset - yPos; // Offset and flip height (canvas Y goes down)

                        Vector2I start = new Vector2I(0, yPos);
                        Vector2I end   = new Vector2I((int)(width * strength), yPos);

                        Color color = COLOR_TRANSPARENT_LIGHT_GRAY;
                        color.a *= strength;

                        canvas.DrawLine(start, end, color);

                        // Draw text for the highest level ticks
                        if (i == 0)
                        {
                            DrawValue(yPos, ticks[j], ticks[j] <= 0.0f);
                        }
                    }
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Rebuilds the internal GUI elements. Should be called whenever timeline properties change.
 /// </summary>
 public virtual void Rebuild()
 {
     canvas.Clear();
 }