// preview a frame in the scene view public override void previewFrame(float frame, AMTrack extraTrack = null) { if (!obj) { return; } if (cache.Count <= 0) { return; } // if before first frame if (frame <= (float)cache[0].startFrame) { obj.position = (cache[0] as AMTranslationAction).path[0]; return; } // if beyond last frame if (frame >= (float)(cache[cache.Count - 1] as AMTranslationAction).endFrame) { obj.position = (cache[cache.Count - 1] as AMTranslationAction).path[(cache[cache.Count - 1] as AMTranslationAction).path.Length - 1]; return; } // if lies on curve foreach (AMTranslationAction action in cache) { if (((int)frame < action.startFrame) || ((int)frame > action.endFrame)) { continue; } if (action.path.Length == 1) { obj.position = action.path[0]; return; } float _value; float framePositionInPath = frame - (float)action.startFrame; if (framePositionInPath < 0f) { framePositionInPath = 0f; } AMTween.EasingFunction ease; AnimationCurve curve = null; if (action.hasCustomEase()) { ease = AMTween.customEase; curve = action.easeCurve; } else { ease = AMTween.GetEasingFunction((AMTween.EaseType)action.easeType); } _value = ease(0f, 1f, framePositionInPath / action.getNumberOfFrames(), curve); AMTween.PutOnPath(obj, action.path, Mathf.Clamp(_value, 0f, 1f)); return; } }