public void AddTag(Type tagType, float startTime = 0f, float duration = -1f) { if (!Valid) { return; } if (duration < 0) { duration = DurationInSeconds - startTime; } int existing = tags.Count(t => t.Type == tagType && FloatComparer.AreEqual(t.startTime, startTime, FloatComparer.kEpsilon) && FloatComparer.AreEqual(t.duration, duration, FloatComparer.kEpsilon)); if (existing > 0) { return; } Undo.RecordObject(m_Asset, $"Add {TagAttribute.GetDescription(tagType)} tag"); TagAnnotation newTag = TagAnnotation.Create(tagType, startTime, duration); tags.Add(newTag); NotifyChanged(); }
TaggedAnimationClip(AnimationClip animationClip, Asset asset, ETagImportOption tagImportOption) { m_Asset = asset; SetClip(animationClip); foreach (var method in Utility.GetExtensionMethods(GetType())) { method.Invoke(null, new object[] { this, tagImportOption }); } if (tagImportOption == ETagImportOption.AddDefaultTag) { object tag = DefaultTagAttribute.CreateDefaultTag(); if (tag != null) { TagAnnotation tagAnnotation = TagAnnotation.Create(tag.GetType(), 0.0f, DurationInSeconds); tagAnnotation.payload.SetValueObject(tag); AddTag(tagAnnotation); } } if (animationClip.isLooping) { TaggedPreBoundaryClip = this; TaggedPostBoundaryClip = this; } // Obsolete V1 variables m_PreBoundaryClip = null; m_PostBoundaryClip = null; }