Beispiel #1
0
        public static void SetItemInformation(int id, Rect rect)
        {
            if (!Preferences.Enabled)
            {
                return;
            }

            using (ProfilerSample.Get("Enhanced Hierarchy"))
                using (ProfilerSample.Get())
                    try {
                        CurrentGameObject = EditorUtility.InstanceIDToObject(id) as GameObject;

                        IsGameObject   = CurrentGameObject;
                        IsRepaintEvent = Event.current.type == EventType.Repaint;
                        IsFirstVisible = Event.current.type != LastEventType;
                        LastEventType  = Event.current.type;

                        if (IsGameObject)
                        {
                            GameObjectName = CurrentGameObject.name;

                            try {
                                GameObjectTag = CurrentGameObject.tag;
                            } catch { // I couldn't reproduce this, but it can happen
                                if (Preferences.DebugEnabled)
                                {
                                    Debug.LogWarning("Invalid gameobject tag", CurrentGameObject);
                                }
                                GameObjectTag = "Untagged";
                            }

                            LabelSize  = EditorStyles.label.CalcSize(Utility.GetTempGUIContent(GameObjectName)).x;
                            LabelSize += Reflected.IconWidth + 5f; // Icon size
                            var labelOnlyRect = rect;
                            labelOnlyRect.xMax = labelOnlyRect.xMin + LabelSize;
                            LabelOnlyRect      = labelOnlyRect;
                            HasTag             = !CurrentGameObject.CompareTag(UNTAGGED) || !Preferences.HideDefaultTag;
                            HasLayer           = CurrentGameObject.layer != UNLAYERED || !Preferences.HideDefaultLayer;
                            CurrentStyle       = Utility.GetHierarchyLabelStyle(CurrentGameObject);
                            CurrentColor       = CurrentStyle.normal.textColor;
                            CurrentGameObject.GetComponents(Components);
                        }

                        if (IsFirstVisible)
                        {
                            FinalRect = RawRect;
                        }

                        RawRect   = rect;
                        rect.xMin = 0f;
                        //rect.xMax = EditorGUIUtility.currentViewWidth;
                        FullSizeRect = rect;
                    } catch (Exception e) {
                        Utility.LogException(e);
                    }
        }
        public static void SetItemInformation(int id, Rect rect)
        {
            if (!Preferences.Enabled)
            {
                return;
            }

            using (ProfilerSample.Get("Enhanced Hierarchy"))
                using (ProfilerSample.Get())
                    try {
                        CurrentGameObject = EditorUtility.InstanceIDToObject(id) as GameObject;

                        IsGameObject   = CurrentGameObject;
                        IsRepaintEvent = Event.current.type == EventType.Repaint;
                        IsFirstVisible = Event.current.type != LastEventType;
                        LastEventType  = Event.current.type;

                        if (IsGameObject)
                        {
                            GameObjectName = CurrentGameObject.name;
                            GameObjectTag  = CurrentGameObject.tag;
                            LabelSize      = EditorStyles.label.CalcSize(Utility.GetTempGUIContent(GameObjectName)).x;
                            HasTag         = !CurrentGameObject.CompareTag(UNTAGGED) || !Preferences.HideDefaultTag;
                            HasLayer       = CurrentGameObject.layer != UNLAYERED || !Preferences.HideDefaultLayer;
                            CurrentStyle   = Utility.GetHierarchyLabelStyle(CurrentGameObject);
                            CurrentColor   = CurrentStyle.normal.textColor;
                            CurrentGameObject.GetComponents(Components);
                        }

                        if (IsFirstVisible)
                        {
                            FinalRect = RawRect;
                        }

                        RawRect      = rect;
                        rect.xMin    = 0f;
                        FullSizeRect = rect;
                    }
                    catch (Exception e) {
                        Utility.LogException(e);
                    }
        }
        private static void TagMiniLabel(ref Rect rect)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            using (ProfilerSample.Get())
                using (new GUIContentColor(CurrentColor * new Color(1f, 1f, 1f, CurrentGameObject.CompareTag(UNTAGGED) ? Styles.backgroundColorDisabled.a : Styles.backgroundColorEnabled.a))) {
                    GUI.changed = false;
                    Styles.miniLabelStyle.fontSize = Preferences.SmallerMiniLabel ? 8 : 9;

                    rect.xMin -= Styles.miniLabelStyle.CalcSize(Utility.GetTempGUIContent(GameObjectTag)).x;

                    var tag = EditorGUI.TagField(rect, GameObjectTag, Styles.miniLabelStyle);

                    if (GUI.changed)
                    {
                        Icons.Tag.ChangeTagAndAskForChildren(GetSelectedObjectsAndCurrent(), tag);
                    }
                }
        }