Example #1
0
        public static bool AreEqual(SequencePath lhs, SequencePath rhs)
        {
            if (ReferenceEquals(lhs, null) && ReferenceEquals(rhs, null))
            {
                return(true);
            }
            if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
            {
                return(false);
            }
            if (ReferenceEquals(lhs, rhs))
            {
                return(true);
            }

            var result = lhs.selectionRoot == rhs.selectionRoot &&
                         lhs.subElements.Count == rhs.subElements.Count;

            if (!result)
            {
                return(false);
            }

            for (int i = 0, n = lhs.subElements.Count; i < n; ++i)
            {
                result = result && SequencePathSubElement.AreEqual(lhs.subElements[i], rhs.subElements[i]);
            }

            return(result);
        }
Example #2
0
        public void FromSequencePath(SequencePath path, bool forceRebuild)
        {
            if (!NeedsUpdate(path, forceRebuild))
            {
                return;
            }

            Clear_Internal();

            var rootObject = EditorUtility.InstanceIDToObject(path.selectionRoot);

            if (rootObject == null)
            {
                UpdateSerializedPath();
                return;
            }

            var candidateAsset = rootObject as TimelineAsset;

            if (candidateAsset != null)
            {
                Add_Internal(candidateAsset, null, null);
                UpdateSerializedPath();
                return;
            }

            var candidateGameObject = rootObject as GameObject;

            if (candidateGameObject == null)
            {
                UpdateSerializedPath();
                return;
            }

            var director = TimelineUtility.GetDirectorComponentForGameObject(candidateGameObject);
            var asset    = TimelineUtility.GetTimelineAssetForDirectorComponent(director);

            Add_Internal(asset, director, null);

            if (!path.subElements.Any())
            {
                UpdateSerializedPath();
                return;
            }

            List <SequenceBuildingBlock> buildingBlocks;

            if (ValidateSubElements(path.subElements, director, out buildingBlocks))
            {
                foreach (var buildingBlock in buildingBlocks)
                {
                    Add_Internal(buildingBlock.asset, buildingBlock.director, buildingBlock.hostClip);
                }
            }

            UpdateSerializedPath();
        }
Example #3
0
        void OnEnable()
        {
            if (m_SequencePath == null)
            {
                m_SequencePath = new SequencePath();
            }

            if (m_SequenceHierarchy == null)
            {
                // The sequence hierarchy will become null if maximize on play is used for in/out of playmode
                // a static var will hang on to the reference
                if (s_LastHierarchy != null)
                {
                    m_SequenceHierarchy = s_LastHierarchy;
                }
                else
                {
                    m_SequenceHierarchy = SequenceHierarchy.CreateInstance();
                }

                state = null;
            }
            s_LastHierarchy = m_SequenceHierarchy;

            titleContent = GetLocalizedTitleContent();

            UpdateTitle();

            m_PreviewResizer.Init("TimelineWindow");

            // Unmaximize fix : when unmaximizing, a new window is enabled and disabled. Prevent it from overriding the instance pointer.
            if (instance == null)
            {
                instance = this;
            }

            AnimationClipCurveCache.Instance.OnEnable();
            TrackAsset.OnClipPlayableCreate           += m_PlayableLookup.UpdatePlayableLookup;
            TrackAsset.OnTrackAnimationPlayableCreate += m_PlayableLookup.UpdatePlayableLookup;

            if (state == null)
            {
                state = new WindowState(this, s_LastHierarchy);
                Initialize();
                RefreshSelection(true);
                m_ForceRefreshLastSelection = true;
            }
        }
        public void SetCurrentSequencePath(SequencePath path, bool forceRebuild)
        {
            if (!m_SequenceHierarchy.NeedsUpdate(path, forceRebuild))
            {
                return;
            }

            if (OnBeforeSequenceChange != null)
            {
                OnBeforeSequenceChange.Invoke();
            }

            m_SequenceHierarchy.FromSequencePath(path, forceRebuild);

            if (OnAfterSequenceChange != null)
            {
                OnAfterSequenceChange.Invoke();
            }
        }
Example #5
0
        public SequencePath ToSequencePath()
        {
            var path = new SequencePath();

            if (m_Sequences.Count == 0)
            {
                return(path);
            }

            var rootSequence = m_Sequences[0];
            var root         = 0;

            if (rootSequence.director != null && rootSequence.director.gameObject != null)
            {
                root = rootSequence.director.gameObject.GetInstanceID();
            }
            else if (rootSequence.asset != null)
            {
                root = rootSequence.asset.GetInstanceID();
            }

            path.SetSelectionRoot(root);

            var resolver = rootSequence.director;

            if (m_Sequences.Count > 1)
            {
                for (int i = 1, n = m_Sequences.Count; i < n; ++i)
                {
                    path.AddSubSequence(m_Sequences[i], resolver);
                    resolver = m_Sequences[i].director;
                }
            }

            return(path);
        }
Example #6
0
 void UpdateSerializedPath()
 {
     m_SerializedPath = ToSequencePath();
 }
Example #7
0
 public bool NeedsUpdate(SequencePath path, bool forceRebuild)
 {
     return(forceRebuild || !SequencePath.AreEqual(m_SerializedPath, path));
 }