public static string TimeAsFrames(double timeValue, double frameRate, string format = "F2") { string result; if (TimeUtility.OnFrameBoundary(timeValue, frameRate)) { result = TimeUtility.ToFrames(timeValue, frameRate).ToString(); } else { result = TimeUtility.ToExactFrames(timeValue, frameRate).ToString(format); } return(result); }
public static string TimeAsTimeCode(double timeValue, double frameRate, string format = "F2") { TimeUtility.ValidateFrameRate(frameRate); int num = (int)Math.Abs(timeValue); int num2 = num / 3600; int num3 = num % 3600 / 60; int num4 = num % 60; string str = (timeValue >= 0.0) ? string.Empty : "-"; string str2; if (num2 > 0) { str2 = string.Concat(new string[] { num2.ToString(), ":", num3.ToString("D2"), ":", num4.ToString("D2") }); } else { if (num3 > 0) { str2 = num3.ToString() + ":" + num4.ToString("D2"); } else { str2 = num4.ToString(); } } int totalWidth = (int)Math.Floor(Math.Log10(frameRate) + 1.0); string text = (TimeUtility.ToFrames(timeValue, frameRate) - TimeUtility.ToFrames((double)num, frameRate)).ToString().PadLeft(totalWidth, '0'); if (!TimeUtility.OnFrameBoundary(timeValue, frameRate)) { string text2 = TimeUtility.ToExactFrames(timeValue, frameRate).ToString(format); int num5 = text2.IndexOf('.'); if (num5 >= 0) { text = text + " [" + text2.Substring(num5) + "]"; } } return(str + str2 + ":" + text); }
protected void DrawTimeCodeGUI(bool setBeginTime = true) { string text; if (_simpleTimeArea != null) { double time01 = setBeginTime ? this.RunningTime : this.CutOffTime; text = this.TimeAsString(time01, "F2"); bool flag = TimeUtility.OnFrameBoundary(time01, (double)this._frameRate); if (this._timeInFrames) { if (flag) { text = setBeginTime ? RunningFrame.ToString() : CutOffFrame.ToString(); } else { text = TimeUtility.ToExactFrames(time01, (double)this._frameRate).ToString("F2"); } } } else { text = "0"; } EditorGUI.BeginChangeCheck(); string text2 = EditorGUILayout.DelayedTextField(text, EditorStyles.toolbarTextField, new GUILayoutOption[] { GUILayout.Width(70f) }); bool flag2 = EditorGUI.EndChangeCheck(); if (flag2) { if (_timeInFrames) { int frame = setBeginTime ? RunningFrame : CutOffFrame; double d = 0.0; if (double.TryParse(text2, out d)) { frame = Math.Max(0, (int)Math.Floor(d)); } if (setBeginTime) { RunningFrame = frame; } else { CutOffFrame = frame; } } else { double num = TimeUtility.ParseTimeCode(text2, (double)this._frameRate, -1.0); if (num > 0.0) { if (setBeginTime) { RunningTime = (float)num; } else { CutOffTime = (float)num; } } } } }
public static bool OnFrameBoundary(double time, double frameRate) { return(TimeUtility.OnFrameBoundary(time, frameRate, Math.Max(time, 1.0) * frameRate * TimeUtility.kTimeEpsilon)); }