void DoBreadcrumbGUI()
        {
            if (state == null)
                return;
            int count = 0;
            foreach (var sequence in state.GetAllSequences())
            {
                BreadCrumbTitle title = new BreadCrumbTitle()
                {
                    name = DisplayNameHelper.GetDisplayName(sequence),
                    mode = GetTitleMode(sequence)
                };
                if (count >= m_BreadCrumbLabels.Count)
                    m_BreadCrumbLabels.Add(title);
                else
                    m_BreadCrumbLabels[count] = title;
                count++;
            }

            if (m_BreadCrumbLabels.Count > count)
                m_BreadCrumbLabels.RemoveRange(count, m_BreadCrumbLabels.Count - count);

            using (new EditorGUI.DisabledScope(currentMode.headerState.breadCrumb == TimelineModeGUIState.Disabled))
            {
                BreadcrumbDrawer.Draw(breadCrumbAreaWidth, m_BreadCrumbLabels, NavigateToBreadcrumbIndex);
            }
        }
        static Rect DrawActiveBreadcrumb(int width, BreadCrumbTitle label, GUIStyle style, GUIStyle backgroundStyle)
        {
            var content = GetTextContent(width, label, style);
            var rect    = GetBreadcrumbLayoutRect(content, style);

            if (Event.current.type == EventType.Repaint)
            {
                backgroundStyle.Draw(rect, GUIContent.none, 0);
            }

            if (GUI.Button(rect, content, style))
            {
                UnityEngine.Object target = TimelineEditor.inspectedDirector;
                if (target == null)
                {
                    target = TimelineEditor.inspectedAsset;
                }
                if (target != null)
                {
                    bool ping = true;
                    if (label.mode == TitleMode.PrefabOutOfContext)
                    {
                        var gameObject = PrefabUtility.GetRootGameObject(target);
                        if (gameObject != null)
                        {
                            target = gameObject;  // ping the prefab root if it's locked.
                            if (!TimelineWindow.instance.locked)
                            {
                                var assetPath = AssetDatabase.GetAssetPath(gameObject);
                                if (!string.IsNullOrEmpty(assetPath))
                                {
                                    var stage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.OpenPrefab(assetPath);
                                    if (stage != null)
                                    {
                                        ping = false;
                                    }
                                }
                            }
                        }
                    }

                    if (ping)
                    {
                        EditorGUIUtility.PingObject(target);
                    }
                }
            }

            return(rect);
        }
        static void DrawBreadcrumbAsSelectedSubSequence(int width, BreadCrumbTitle label, GUIStyle style, GUIStyle backgroundStyle)
        {
            var         rect = DrawActiveBreadcrumb(width, label, style, backgroundStyle);
            const float underlineThickness        = 2.0f;
            const float underlineVerticalOffset   = 0.0f;
            var         underlineHorizontalOffset = backgroundStyle.border.right * 0.333f;
            var         underlineRect             = Rect.MinMaxRect(
                rect.xMin - underlineHorizontalOffset,
                rect.yMax - underlineThickness - underlineVerticalOffset,
                rect.xMax - underlineHorizontalOffset,
                rect.yMax - underlineVerticalOffset);

            EditorGUI.DrawRect(underlineRect, DirectorStyles.Instance.customSkin.colorSubSequenceDurationLine);
        }
        static GUIContent GetTextContent(int width, BreadCrumbTitle text, GUIStyle style)
        {
            s_TextContent.tooltip = string.Empty;
            s_TextContent.image   = null;
            if (text.mode == TitleMode.DisabledComponent)
            {
                s_TextContent.tooltip = k_DisabledComponentText;
                s_TextContent.image   = EditorGUIUtility.GetHelpIcon(MessageType.Warning);
            }
            else if (text.mode == TitleMode.Prefab)
            {
                s_TextContent.image = PrefabUtility.GameObjectStyles.prefabIcon;
            }
            else if (text.mode == TitleMode.GameObject)
            {
                s_TextContent.image = PrefabUtility.GameObjectStyles.gameObjectIcon;
            }
            else if (text.mode == TitleMode.Asset)
            {
                s_TextContent.image = k_TimelineIcon;
            }
            else if (text.mode == TitleMode.PrefabOutOfContext)
            {
                s_TextContent.image = PrefabUtility.GameObjectStyles.prefabIcon;
                if (!TimelineWindow.instance.locked)
                {
                    s_TextContent.tooltip = k_PrefabOutOfContext;
                }
            }

            if (s_TextContent.image != null)
            {
                width = Math.Max(0, width - s_TextContent.image.width);
            }
            s_TextContent.text = FitTextInArea(width, text.name, style);

            return(s_TextContent);
        }
Exemplo n.º 5
0
        void DrawBreadcrumbs()
        {
            if (state == null)
            {
                return;
            }
            var count = 0;

            foreach (var sequence in state.GetAllSequences())
            {
                var title = new BreadCrumbTitle
                {
                    name = DisplayNameHelper.GetDisplayName(sequence),
                    mode = GetTitleMode(sequence)
                };
                if (count >= m_BreadCrumbLabels.Count)
                {
                    m_BreadCrumbLabels.Add(title);
                }
                else
                {
                    m_BreadCrumbLabels[count] = title;
                }
                count++;
            }

            if (m_BreadCrumbLabels.Count > count)
            {
                m_BreadCrumbLabels.RemoveRange(count, m_BreadCrumbLabels.Count - count);
            }

            using (new EditorGUI.DisabledScope(currentMode.headerState.breadCrumb == TimelineModeGUIState.Disabled))
            {
                var width = position.width - WindowConstants.playControlsWidth - WindowConstants.cogButtonWidth;
                BreadcrumbDrawer.Draw(width, m_BreadCrumbLabels, NavigateToBreadcrumbIndex);
            }
        }