// A log item is clicked, highlight it
        public void OnLogItemClicked(DebugLogItem item)
        {
            if (indexOfSelectedLogEntry != item.Index)
            {
                DeselectSelectedLogItem();

                indexOfSelectedLogEntry       = item.Index;
                positionOfSelectedLogEntry    = item.Index * logItemHeight;
                heightOfSelectedLogEntry      = item.CalculateExpandedHeight(item.ToString());
                deltaHeightOfSelectedLogEntry = heightOfSelectedLogEntry - logItemHeight;

                manager.SetSnapToBottom(false);
            }
            else
            {
                DeselectSelectedLogItem();
            }

            if (indexOfSelectedLogEntry >= currentTopIndex && indexOfSelectedLogEntry <= currentBottomIndex)
            {
                ColorLogItem(logItemsAtIndices[indexOfSelectedLogEntry], indexOfSelectedLogEntry);
            }

            CalculateContentHeight();

            HardResetItems();
            UpdateItemsInTheList(true);

            manager.ValidateScrollPosition();
        }
Example #2
0
        // Log window's width has changed, update the expanded (currently selected) log's height
        public void OnViewportWidthChanged()
        {
            if (indexOfSelectedLogEntry >= indicesOfEntriesToShow.Count)
            {
                return;
            }

            if (currentTopIndex == -1)
            {
                UpdateItemsInTheList(false);                // Try to generate some DebugLogItems, we need one DebugLogItem to calculate the text height
                if (currentTopIndex == -1)                  // No DebugLogItems are generated, weird
                {
                    return;
                }
            }

            DebugLogItem referenceItem = logItemsAtIndices[currentTopIndex];

            heightOfSelectedLogEntry      = referenceItem.CalculateExpandedHeight(collapsedLogEntries[indicesOfEntriesToShow[indexOfSelectedLogEntry]].ToString());
            deltaHeightOfSelectedLogEntry = heightOfSelectedLogEntry - logItemHeight;

            CalculateContentHeight();

            HardResetItems();
            UpdateItemsInTheList(true);

            manager.ValidateScrollPosition();
        }
        // Create (or unpool) a log item
        private void CreateLogItemAtIndex(int index)
        {
            DebugLogItem logItem = debugManager.UnpoolLogItem();

            // Reposition the log item
            logItem.Transform.localPosition = new Vector3(1f, -index * logItemHeight, 0f);

            // Color the log item
            ColorLogItem(logItem, index);

            // To access this log item easily in the future, add it to the dictionary
            logItemsAtIndices[index] = logItem;
        }
 // Color a log item using its index
 private void ColorLogItem(DebugLogItem logItem, int index)
 {
     if (index == indexOfSelectedLogEntry)
     {
         logItem.Image.color = logItemSelectedColor;
     }
     else if (index % 2 == 0)
     {
         logItem.Image.color = logItemNormalColor1;
     }
     else
     {
         logItem.Image.color = logItemNormalColor2;
     }
 }
        // Create (or unpool) a log item
        private void CreateLogItemAtIndex(int index)
        {
            DebugLogItem logItem = debugManager.PopLogItem();

            // Reposition the log item
            Vector2 anchoredPosition = new Vector2(1f, -index * logItemHeight);

            if (index > indexOfSelectedLogEntry)
            {
                anchoredPosition.y -= deltaHeightOfSelectedLogEntry;
            }

            logItem.Transform.anchoredPosition = anchoredPosition;

            // Color the log item
            ColorLogItem(logItem, index);

            // To access this log item easily in the future, add it to the dictionary
            logItemsAtIndices[index] = logItem;
        }
        private void OnLogItemClickedInternal(int itemIndex, DebugLogItem referenceItem = null)
        {
            if (indexOfSelectedLogEntry != itemIndex)
            {
                DeselectSelectedLogItem();

                if (!referenceItem)
                {
                    if (currentTopIndex == -1)
                    {
                        UpdateItemsInTheList(false);                           // Try to generate some DebugLogItems, we need one DebugLogItem to calculate the text height
                    }
                    referenceItem = logItemsAtIndices[currentTopIndex];
                }

                indexOfSelectedLogEntry       = itemIndex;
                positionOfSelectedLogEntry    = itemIndex * logItemHeight;
                heightOfSelectedLogEntry      = referenceItem.CalculateExpandedHeight(collapsedLogEntries[indicesOfEntriesToShow[itemIndex]].ToString());
                deltaHeightOfSelectedLogEntry = heightOfSelectedLogEntry - logItemHeight;

                manager.SetSnapToBottom(false);
            }
            else
            {
                DeselectSelectedLogItem();
            }

            if (indexOfSelectedLogEntry >= currentTopIndex && indexOfSelectedLogEntry <= currentBottomIndex)
            {
                ColorLogItem(logItemsAtIndices[indexOfSelectedLogEntry], indexOfSelectedLogEntry);
            }

            CalculateContentHeight();

            HardResetItems();
            UpdateItemsInTheList(true);

            manager.ValidateScrollPosition();
        }
Example #7
0
 // Pool an unused log item
 public void PoolLogItem(DebugLogItem logItem)
 {
     logItem.gameObject.SetActive(false);
     pooledLogItems.Add(logItem);
 }
 // A log item is clicked, highlight it
 public void OnLogItemClicked(DebugLogItem item)
 {
     OnLogItemClickedInternal(item.Index, item);
 }
 public void Initialize(DebugLogItem logItem)
 {
     this.logItem = logItem;
 }