示例#1
0
        public double SnapToFrameIfRequired(double time)
        {
            double result;

            if (this._frameSnap)
            {
                result = TimeUtility.FromFrames(TimeUtility.ToFrames(time, (double)this._frameRate), (double)this._frameRate);
            }
            else
            {
                result = time;
            }
            return(result);
        }
示例#2
0
        public string TimeAsString(double timeValue, string format = "F2")
        {
            string result;

            if (this._timeInFrames)
            {
                result = TimeUtility.TimeAsFrames(timeValue, (double)this._frameRate, format);
            }
            else
            {
                result = TimeUtility.TimeAsTimeCode(timeValue, (double)this._frameRate, format);
            }
            return(result);
        }
示例#3
0
        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;
                        }
                    }
                }
            }
        }
示例#4
0
 public static bool OnFrameBoundary(double time, double frameRate)
 {
     return(TimeUtility.OnFrameBoundary(time, frameRate, Math.Max(time, 1.0) * frameRate * TimeUtility.kTimeEpsilon));
 }
示例#5
0
 public static double FromFrames(double frames, double frameRate)
 {
     TimeUtility.ValidateFrameRate(frameRate);
     return(frames / frameRate);
 }
示例#6
0
 public static double ToExactFrames(double time, double frameRate)
 {
     TimeUtility.ValidateFrameRate(frameRate);
     return(time * frameRate);
 }