Esempio n. 1
0
        private static void OnItemGUI(int id, Rect rect)
        {
            if (!Preferences.Enabled)
            {
                return;
            }

            using (ProfilerSample.Get("Enhanced Hierarchy"))
                try {
                    if (IsGameObject)
                    {
                        foreach (var icon in Preferences.RightIcons.Value)
                        {
                            icon.Init();
                        }

                        foreach (var icon in Preferences.LeftIcons.Value)
                        {
                            icon.Init();
                        }

                        Preferences.LeftSideButton.Value.Init();
                    }

                    SetTitle("EH 2.0");
                    CalculateIconsWidth();
                    DoSelection(RawRect);
                    IgnoreLockedSelection();
                    var trailingWidth = DoTrailing(RawRect);
                    ColorSort(RawRect);
                    DrawTree(RawRect);
                    DrawLeftSideIcons(RawRect);
                    ChildToggle();
                    DrawTooltip(RawRect, trailingWidth);

                    if (IsGameObject)
                    {
                        rect.xMax -= Preferences.Offset;
                        rect.xMin  = rect.xMax;
                        rect.y++;

                        foreach (var icon in Preferences.RightIcons.Value)
                        {
                            try {
                                using (new GUIBackgroundColor(Styles.backgroundColorEnabled)) {
                                    rect.xMin -= icon.Width;
                                    icon.DoGUI(rect);
                                    rect.xMax -= icon.Width;
                                }
                            }
                            catch (Exception e) {
                                Debug.LogException(e);
                                Preferences.ForceDisableButton(icon);
                            }
                        }

                        var leftSideRect = RawRect;

                        try {
                            if (Preferences.LeftmostButton)
                            {
                                leftSideRect.xMin = 0f;
                            }
                            else
                            {
                                leftSideRect.xMin -= 2f + CurrentGameObject.transform.childCount > 0 || Preferences.Tree ? 30f : 18f;
                            }

                            leftSideRect.xMax = leftSideRect.xMin + Preferences.LeftSideButton.Value.Width;

                            using (new GUIBackgroundColor(Styles.backgroundColorEnabled))
                                Preferences.LeftSideButton.Value.DoGUI(leftSideRect);
                        }
                        catch (Exception e) {
                            Debug.LogException(e);
                            Preferences.ForceDisableButton(Preferences.LeftSideButton.Value);
                        }
                    }

                    DrawMiniLabel(ref rect);
                    DrawHorizontalSeparator(RawRect);
                }
                catch (Exception e) {
                    Utility.LogException(e);
                }
        }