//TODO: Only update dirty onGUI on the active selection prefabLink and prefabLinks referencing the active selection.
        // Need a better prefablink prefab map to do this.
        private void UpdateDirtyPrefabLinks()
        {
            if (firstPrefabLink != null)
            {
                float timeSinceStartup = (float)EditorApplication.timeSinceStartup;
                if (timeSinceStartup - firstPrefabLink.updateDirtyStartTime > 1 / PrefabLink.dirtyChecksPerSecond)
                {
                    firstPrefabLink.UpdateDirty();
                    firstPrefabLink.updateDirtyStartTime = timeSinceStartup;

                    EditorApplication.RepaintHierarchyWindow();
                }
            }
        }
        private static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
        {
            UnityEngine.Object obj = EditorUtility.InstanceIDToObject(instanceID);

            if (obj != null)
            {
                if (obj is GameObject)
                {
                    GameObject gameObject = obj as GameObject;
                    PrefabLink prefabLink = gameObject.gameObject.GetComponent <PrefabLink>();

                    if (prefabLink != null)
                    {
                        FontStyle prefabLinkFontStyle = FontStyle.Normal;
                        Color     prefabLinkColor     = textEditorBlack;
                        Color     backgroundColor     = editorGray;

                        float timeSinceStartup = (float)EditorApplication.timeSinceStartup;
                        if (timeSinceStartup - prefabLink.updateDirtyStartTime > 1 / PrefabLink.dirtyChecksPerSecond)
                        {
                            prefabLink.UpdateDirty();
                            prefabLink.updateDirtyStartTime = timeSinceStartup;
                        }

                        bool selected = Selection.instanceIDs.Contains(instanceID);
                        bool disabled = !gameObject.activeInHierarchy;
                        bool noTarget = prefabLink.target == null;
                        bool dirty    = prefabLink.Dirty;

                        if (dirty || noTarget)
                        {
                            prefabLinkFontStyle = FontStyle.Bold;
                        }

                        if (selected)
                        {
                            backgroundColor = selectedBackgroundBlue;
                        }

                        if (noTarget)
                        {
                            if (selected)
                            {
                                prefabLinkColor = textNoTargetSelected;
                            }
                            else if (disabled)
                            {
                                prefabLinkColor = textNoTargetDisabled;
                            }
                            else
                            {
                                prefabLinkColor = textNoTargetDefault;
                            }
                        }
                        else
                        {
                            if (selected)
                            {
                                prefabLinkColor = textNormalSelected;
                            }
                            else if (disabled)
                            {
                                prefabLinkColor = textNormalDisabled;
                            }
                            else
                            {
                                prefabLinkColor = textNormalDefault;
                            }
                        }

                        Rect offsetRect = new Rect(selectionRect.position + new Vector2(0, 2), selectionRect.size);
                        EditorGUI.DrawRect(selectionRect, backgroundColor);
                        EditorGUI.LabelField(offsetRect, obj.name, new GUIStyle()
                        {
                            normal = new GUIStyleState()
                            {
                                textColor = prefabLinkColor
                            },
                            fontStyle = prefabLinkFontStyle
                        });
                    }
                }
            }
        }