public void Play(string animationName, float offsetSeconds) { var frameInformation = FrameInformations.First(x => x.Name == animationName); currentState = frameInformation; isLoop = currentState.IsLoop; deltaTime = 0; PropertyBlockController.SetFloat("_OffsetSeconds", offsetSeconds); PropertyBlockController.SetFloat("_StartFrame", frameInformation.StartFrame); PropertyBlockController.SetFloat("_EndFrame", frameInformation.EndFrame); PropertyBlockController.SetFloat("_FrameCount", frameInformation.FrameCount); PropertyBlockController.Apply(); IsPlaying = true; }
public void OnPostDraw() { if (m_SelectedAnimFrame.IsValid) { AnimationDebugRecord animStateRecord = Debugger.frameDebugger.FindAggregate <AnimationDebugRecord>(m_SelectedAnimFrame.providerIdentifier); if (animStateRecord == null) { m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid(); return; } Assert.IsTrue(m_SelectedAnimFrame.animIndex < animStateRecord.AnimationRecords.Count); if (m_SelectedAnimFrame.animIndex >= animStateRecord.AnimationRecords.Count) { m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid(); return; } AnimationRecord animRecord = animStateRecord.AnimationRecords[m_SelectedAnimFrame.animIndex]; Assert.IsTrue(m_SelectedAnimFrame.animFrameIndex < animRecord.animFrames.Count); if (m_SelectedAnimFrame.animFrameIndex >= animRecord.animFrames.Count) { m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid(); return; } AnimationFrameInfo animFrame = animRecord.animFrames[m_SelectedAnimFrame.animFrameIndex]; string label = $"{animRecord.animName}\nFrame:{animFrame.animFrame:0.00}\nWeight:{animFrame.weight:0.00}"; Vector2 labelSize = TimelineWidget.GetLabelSize(label); Rect toolTipRect = new Rect(Event.current.mousePosition.x + 20, Event.current.mousePosition.y, labelSize.x + 5.0f, labelSize.y + 5.0f); TimelineWidget.DrawRectangleWithDetour(toolTipRect, kTooltipBackgroundColor, kTooltipDetourColor); TimelineWidget.DrawLabel(toolTipRect, label, kTooltipTextColor); m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid(); } }