static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            s_GlobalCallbackSet.OnImport();
            s_GlobalCallbackSet.OnDelete();

            foreach (string path in importedAssets)
            {
                SerializableGuid guid = SerializableGuidUtility.GetSerializableGuidFromAssetPath(path);

                CallbackSet callbacks;
                if (s_CallbackSetsPerClip.TryGetValue(guid, out callbacks))
                {
                    callbacks.OnImport();
                }
            }

            foreach (string path in deletedAssets)
            {
                SerializableGuid guid = SerializableGuidUtility.GetSerializableGuidFromAssetPath(path);

                CallbackSet callbacks;
                if (s_CallbackSetsPerClip.TryGetValue(guid, out callbacks))
                {
                    callbacks.OnDelete();
                }
            }
        }
        /// <summary>
        /// Removes the TaggedAnimationClip that corresponds to the supplied AnimationClip from the asset
        /// </summary>
        /// <param name=clip>AnimationClip to use</param>
        /// <returns>true if the clip was found and removed, false otherwise</returns>
        public bool RemoveAnimationClip(AnimationClip clip)
        {
            if (clip == null)
            {
                throw new ArgumentNullException("clip");
            }

            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            Undo.RecordObject(this, string.Format("Remove Animation Clip {0}", clip.name));

            int removed = AnimationLibrary.RemoveAll((TaggedAnimationClip tagged) => { return(tagged.AnimationClipGuid == clipGuid); });

            if (removed > 0)
            {
                MarkDirty();
            }

            return(removed > 0);
        }
示例#3
0
        void SetClip(AnimationClip clip)
        {
            if (clip == null)
            {
                m_Clip = null;
                return;
            }

            AnimationClipPostprocessor.RemoveOnImport(m_AnimationClipGuid, ReloadClipAndMarkDirty);
            AnimationClipPostprocessor.RemoveOnDelete(m_AnimationClipGuid, OnDeleteClip);

            m_AnimationClipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            AnimationClipPostprocessor.AddOnImport(m_AnimationClipGuid, ReloadClipAndMarkDirty);
            AnimationClipPostprocessor.AddOnDelete(m_AnimationClipGuid, OnDeleteClip);

            m_Clip = clip;
            m_CachedClipVersion  = AnimationClipPostprocessor.GetClipVersion(clip);
            m_CachedClipName     = clip.name;
            m_CachedClipDuration = Utility.ComputeAccurateClipDuration(clip);
            m_CachedSampleRate   = clip.frameRate;
        }
        /// <summary>
        /// Creates and adds a new TaggedAnimationClip in the asset from an AnimationClip
        /// </summary>
        /// <completionlist cref=""/>
        /// <param name=clip>AnimationClip to use. Must be an asset on disk</param>
        /// <exception cref="System.ArgumentNullException">Thrown if argument clip is null</exception>
        /// <exception cref="System.ArgumentException">Thrown if argument clip no an asset on disk</exception>
        /// <returns>Returns the TaggedAnimationClip created from the supplied AnimationClip</returns>
        internal TaggedAnimationClip AddAnimationClip(AnimationClip clip)
        {
            if (clip == null)
            {
                throw new ArgumentNullException("clip");
            }

            TaggedAnimationClip taggedAnimationClip = null;

            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            if (!clipGuid.IsSet())
            {
                throw new ArgumentException("argument \"clip\" must be an asset on the disk");
            }

            //Don't add existing AnimationClip to library
            if (AnimationLibrary.Any((TaggedAnimationClip taggedClip) => { return(taggedClip.AnimationClipGuid == clipGuid); }))
            {
                return(null);
            }

            try
            {
                taggedAnimationClip = TaggedAnimationClip.BuildFromClip(clip, this, ETagImportOption.Import);
            }
            catch (InvalidOperationException)
            {
                throw new ArgumentException("argument \"clip\" must be an asset on disk");
            }

            Undo.RecordObject(this, string.Format("Add Animation Clip {0}", clip.name));
            AnimationLibrary.Add(taggedAnimationClip);
            taggedAnimationClip.DataChanged += MarkDirty;

            MarkDirty();
            return(taggedAnimationClip);
        }
        /// <summary>
        /// Finds the TaggedAnimationClip that corresponds to the supplied AnimationClip
        /// </summary>
        /// <param name=clip>AnimationClip to use</param>
        /// <returns>Returns the TaggedAnimationClip associated with the supplied AnimationClip</returns>
        internal TaggedAnimationClip FindTaggedAnimationClip(AnimationClip clip)
        {
            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            return(AnimationLibrary.FirstOrDefault((TaggedAnimationClip taggedClip) => { return taggedClip.AnimationClipGuid == clipGuid; }));
        }
        /// <summary>
        /// TaggedAnimationClip that corresponds to the supplied AnimationClip
        /// </summary>
        /// <param name=clip>AnimationClip to use</param>
        /// <returns>Returns the TaggedAnimationClip associated with the supplied AnimationClip</returns>
        public bool ContainsAnimationClip(AnimationClip clip)
        {
            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            return(AnimationLibrary.Any((TaggedAnimationClip taggedClip) => { return taggedClip.AnimationClipGuid == clipGuid; }));
        }