/// <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> /// 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; })); }