private static void DrawTooltip(Rect rect, float fullTrailingWidth)
        {
            if (!Preferences.Tooltips || !IsGameObject || !IsRepaintEvent)
            {
                return;
            }

            using (ProfilerSample.Get()) {
                if (DragSelection != null)
                {
                    return;
                }

                rect.xMax = Mathf.Min(fullTrailingWidth, rect.xMin + LabelSize);
                rect.xMin = 0f;

                if (!Utility.ShouldCalculateTooltipAt(rect))
                {
                    return;
                }

                var tooltip = new StringBuilder(100);

                tooltip.AppendLine(GameObjectName);
                tooltip.AppendFormat("\nTag: {0}", GameObjectTag);
                tooltip.AppendFormat("\nLayer: {0}", LayerMask.LayerToName(CurrentGameObject.layer));

                if (GameObjectUtility.GetStaticEditorFlags(CurrentGameObject) != 0)
                {
                    tooltip.AppendFormat("\nStatic: {0}", Utility.EnumFlagsToString(GameObjectUtility.GetStaticEditorFlags(CurrentGameObject)));
                }

                tooltip.AppendLine();
                tooltip.AppendLine();

                var components = CurrentGameObject.GetComponents <Component>();

                foreach (var component in components)
                {
                    if (component is Transform)
                    {
                        continue;
                    }
                    else if (component)
                    {
                        tooltip.AppendLine(ObjectNames.GetInspectorTitle(component));
                    }
                    else
                    {
                        tooltip.AppendLine("Missing Component");
                    }
                }

                EditorGUI.LabelField(rect, Utility.GetTempGUIContent(null, tooltip.ToString().TrimEnd('\n', '\r')));
            }
        }
        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);
                    }
                }
        }
Exemple #5
0
    private static void Set()
    {
        //Check If The User Has Even Got A GameObject Selected - Prevents NullReferenceExceptions Due To Such.
        if (Selection.gameObjects.Length == 0)
        {
            Debug.LogError("You Have No GameObjects Selected!");

            return;
        }

        //Define Object Reference
        GameObject RootArmature = null;

        //Define Variables
        int DynBonesFound = 0;

        //Retrieve The Armature Of The Avatar
        //Enumerate The First Child GameObject Of Each GameObject
        for (int i = 0; i < Selection.activeGameObject.transform.root.childCount; i++)
        {
            //Object Reference
            GameObject obj2 = Selection.activeGameObject.transform.root.GetChild(i).gameObject;

            //Check If Found GameObject Is The Armature
            if (obj2.name == "Armature")
            {
                //If So, Add It To The Object Reference For Later Use
                RootArmature = obj2;
                break;
            }
        }

        //If No Armature Was Found, Don't Continue
        if (RootArmature == null)
        {
            Debug.LogError("Armature == null!");

            return;
        }

        //Recursively Check Every GameObject In The Armature For DynamicBoneColliders
        Helpers.CheckTransform(RootArmature.transform);

        //Check If No DynamicBoneColliders Were Found - Prevents NullReferenceExceptions Due To Such.
        if (Helpers.DynamicBoneColliders == null)
        {
            Debug.LogError("Helpers.DynamicBoneColliders == null!");

            return;
        }

        //Enumerate Selected GameObjects
        foreach (var CurrentGameObject in Selection.gameObjects)
        {
            //Ignore Empty GameObjects
            if (CurrentGameObject == null)
            {
                continue;
            }

            //Enumerate DynamicBones On GameObject
            foreach (DynamicBone DynBone in CurrentGameObject.GetComponents <DynamicBone>())
            {
                //Ignore Invalid DynamicBone Components In GameObject
                if (DynBone == null)
                {
                    continue;
                }

                //Raise DynBonesFound By 1
                DynBonesFound++;

                //Set Colliders On DynamicBone
                DynBone.m_Colliders = Helpers.DynamicBoneColliders;
            }
        }

        //If No DynamicBones Were Found And Therefore Effected, Print To Console
        if (DynBonesFound == 0)
        {
            Debug.LogError("No Dynamic Bones Were Found So None Were Effected!");
        }
    }