Ejemplo n.º 1
0
        private bool RenderTimelineList()
        {
            bool didChangeProfile = false;

            RenderSectionTitle("Timeline Animated Properties", "TimelineSectionIcon");

            EditorGUILayout.Space();

            List <ProfileGroupDefinition> onTimeline  = m_Profile.GetGroupDefinitionsManagedByTimeline();
            List <ProfileGroupDefinition> offTimeline = m_Profile.GetGroupDefinitionsNotManagedByTimeline();

            int  deleteIndex = -1;
            bool didSwapRows = false;
            int  swapIndex1  = -1;
            int  swapIndex2  = -1;

            if (onTimeline.Count == 0)
            {
                // Show definition message if no items added yet.
                EditorGUILayout.HelpBox("You can animate properties by adding them to the timeline.", MessageType.None);
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                List <string> timelineTitles = GetTitlesForGroups(onTimeline);

                StringTableListGUI.RenderTableList(
                    timelineTitles,
                    out deleteIndex,
                    out didSwapRows,
                    out swapIndex1,
                    out swapIndex2);

                // Check for table modification events (remove, reorder, etc.)
                if (EditorGUI.EndChangeCheck())
                {
                    didChangeProfile = true;
                    if (deleteIndex != -1)
                    {
                        string deleteGroupKey = onTimeline[deleteIndex].propertyKey;

                        IKeyframeGroup group = m_Profile.GetGroup(deleteGroupKey);
                        if (SkyEditorUtility.IsGroupSelectedOnTimeline(group.id))
                        {
                            TimelineSelection.Clear();

                            // If we deleted a sphere point group make sure to hide the debug dots.
                            if (group is SpherePointKeyframeGroup && m_Profile.skyboxMaterial != null)
                            {
                                m_Profile.skyboxMaterial.DisableKeyword(ShaderKeywords.RenderDebugPoints);
                            }
                        }

                        m_Profile.timelineManagedKeys.Remove(deleteGroupKey);
                        m_Profile.TrimGroupToSingleKeyframe(deleteGroupKey);
                    }
                    else if (didSwapRows)
                    {
                        string tmp = m_Profile.timelineManagedKeys[swapIndex2];
                        m_Profile.timelineManagedKeys[swapIndex2] = m_Profile.timelineManagedKeys[swapIndex1];
                        m_Profile.timelineManagedKeys[swapIndex1] = tmp;
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Open Timeline")))
            {
                SkyTimelineWindow.ShowWindow();
            }

            if (GUILayout.Button(new GUIContent("Add to Timeline")))
            {
                SkyGUITimelineMenu.ShowAddTimelinePropertyMenu(m_Profile, offTimeline);
            }
            EditorGUILayout.EndHorizontal();

            return(didChangeProfile);
        }