///Returns the next local time (clip length) of a loop. public static float GetNextLoopLocalTime(this ISubClipContainable clip) { var clipLength = clip.GetLength(); var loopLength = clip.subClipLength / clip.subClipSpeed; var mod = (clipLength - clip.subClipOffset) % loopLength; var aproxZero = Mathf.Abs(mod) < 0.01f || Mathf.Abs(loopLength - mod) < 0.01f; return(clipLength + (aproxZero ? loopLength : (loopLength - mod))); }
///---------------------------------------------------------------------------------------------- ///Returns the previous local time (clip length) of a loop. public static float GetPreviousLoopLocalTime(this ISubClipContainable clip) { var clipLength = clip.GetLength(); var loopLength = clip.subClipLength / clip.subClipSpeed; if (clipLength > loopLength) { var mod = (clipLength - clip.subClipOffset) % loopLength; var aproxZero = Mathf.Abs(mod) < 0.01f; return(clipLength - (aproxZero ? loopLength : mod)); } return(clipLength); }