Esempio n. 1
0
        private void DrawTrack(Rect rect, Color color, Timeline.TrackEntry trackEntry, float leftTime, float rightTime, float currentTime)
        {
            //Get the items to draw
            trackEntry.Track.GetItems(itemCache);

            //Draw background
            GUI.color = new Color(.3f, .3f, .3f, 1f);
            GUI.DrawTexture(rect, Texture2D.whiteTexture);

            //Draw content
            GUI.color = color;
            for (int i = 0; i < itemCache.Count; i++)
            {
                TimelineItem item          = itemCache[i];
                var          itemStartTime = item.StartTime;
                var          itemStopTime  = item.Running ? currentTime : item.StopTime;
                bool         inView        = MathUtils.DoesRangeOverlap(itemStartTime, itemStopTime, leftTime, rightTime);
                if (inView)
                {
                    //Convert to progress in the view
                    var p1 = Mathf.InverseLerp(leftTime, rightTime, itemStartTime);
                    var p2 = Mathf.InverseLerp(leftTime, rightTime, itemStopTime);

                    Rect itemRect = new Rect(rect.x + p1 * rect.width, rect.y, (p2 - p1) * rect.width, rect.height);
                    GUI.DrawTexture(itemRect, Texture2D.whiteTexture);
                }
            }
        }
 public void LogEndWork()
 {
     threadLock.EnterWriteLock();
     {
         if (count > 0 && items[currentItem].Running)
         {
             TimelineItem current = items[currentItem];
             current.Running    = false;
             current.StopTime   = (float)stopWatch.Elapsed.TotalSeconds;
             items[currentItem] = current;
         }
     }
     threadLock.ExitWriteLock();
 }
 public void LogStartWork()
 {
     threadLock.EnterWriteLock();
     {
         if (started && (count == 0 || !items[currentItem].Running))
         {
             currentItem = (currentItem + 1) % MAX_ITEM_COUNT;
             if (count < MAX_ITEM_COUNT)
             {
                 count++;
             }
             items[currentItem] = new TimelineItem {
                 StartTime = (float)stopWatch.Elapsed.TotalSeconds, Running = true
             };
         }
     }
     threadLock.ExitWriteLock();
 }