static AnimationWindowOptions() { m_TimeFormat = (TimeArea.TimeFormat)EditorPrefs.GetInt(kTimeFormat, (int)TimeArea.TimeFormat.TimeFrame); m_FilterBySelection = EditorPrefs.GetBool(kFilterBySelection, false); m_ShowReadOnly = EditorPrefs.GetBool(kShowReadOnly, false); m_ShowFrameRate = EditorPrefs.GetBool(kShowFrameRate, false); }
public float TimeField(Rect rect, int id, float time, float frameRate, TimeArea.TimeFormat timeFormat) { float result; if (timeFormat == TimeArea.TimeFormat.None) { float time2 = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, rect, new Rect(0f, 0f, 0f, 0f), id, time, EditorGUI.kFloatFieldFormatString, EditorStyles.numberField, false); result = this.SnapTimeToWholeFPS(time2, frameRate); } else if (timeFormat == TimeArea.TimeFormat.Frame) { int value = Mathf.RoundToInt(time * frameRate); int num = EditorGUI.DoIntField(EditorGUI.s_RecycledEditor, rect, new Rect(0f, 0f, 0f, 0f), id, value, EditorGUI.kIntFieldFormatString, EditorStyles.numberField, false, 0f); result = (float)num / frameRate; } else { string text = this.FormatTime(time, frameRate, TimeArea.TimeFormat.TimeFrame); string allowedletters = "0123456789.,:"; bool flag; text = EditorGUI.DoTextField(EditorGUI.s_RecycledEditor, id, rect, text, EditorStyles.numberField, allowedletters, out flag, false, false, false); if (flag) { if (GUIUtility.keyboardControl == id) { GUI.changed = true; text = text.Replace(',', '.'); int num2 = text.IndexOf(':'); float time3; if (num2 >= 0) { string s = text.Substring(0, num2); string s2 = text.Substring(num2 + 1); int num3; int num4; if (int.TryParse(s, out num3) && int.TryParse(s2, out num4)) { float num5 = (float)num3 + (float)num4 / frameRate; result = num5; return(result); } } else if (float.TryParse(text, out time3)) { result = this.SnapTimeToWholeFPS(time3, frameRate); return(result); } } } result = time; } return(result); }
public string FormatTime(float time, float frameRate, TimeArea.TimeFormat timeFormat) { string result; if (timeFormat == TimeArea.TimeFormat.None) { int numberOfDecimalsForMinimumDifference; if (frameRate != 0f) { numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(1f / frameRate); } else { numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(base.shownArea.width / base.drawRect.width); } result = time.ToString("N" + numberOfDecimalsForMinimumDifference); } else { int num = Mathf.RoundToInt(time * frameRate); if (timeFormat == TimeArea.TimeFormat.TimeFrame) { int length = ((int)frameRate).ToString().Length; string str = string.Empty; if (num < 0) { str = "-"; num = -num; } result = str + (num / (int)frameRate).ToString() + ":" + ((float)num % frameRate).ToString().PadLeft(length, '0'); } else { result = num.ToString(); } } return(result); }
public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha, TimeArea.TimeFormat timeFormat) { Color color = GUI.color; GUI.BeginGroup(position); TimeArea.InitStyles(); HandleUtility.ApplyWireMaterial(); Color backgroundColor = GUI.backgroundColor; this.SetTickMarkerRanges(); this.hTicks.SetTickStrengths(3f, 80f, true); Color textColor = TimeArea.styles.timelineTick.normal.textColor; textColor.a = 0.75f * alpha; if (Event.current.type == EventType.Repaint) { if (Application.platform == RuntimePlatform.WindowsEditor) { GL.Begin(7); } else { GL.Begin(1); } Rect shownArea = base.shownArea; for (int i = 0; i < this.hTicks.tickLevels; i++) { float num = this.hTicks.GetStrengthOfLevel(i) * 0.9f; float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true); for (int j = 0; j < ticksAtLevel.Length; j++) { if (ticksAtLevel[j] >= base.hRangeMin && ticksAtLevel[j] <= base.hRangeMax) { int num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate); float num3 = (!useEntireHeight) ? (position.height * Mathf.Min(1f, num) * 0.7f) : position.height; float x = this.FrameToPixel((float)num2, frameRate, position, shownArea); TimeArea.DrawVerticalLineFast(x, position.height - num3 + 0.5f, position.height - 0.5f, new Color(1f, 1f, 1f, num / 0.5f) * textColor); } } } GL.End(); } if (labels) { int levelWithMinSeparation = this.hTicks.GetLevelWithMinSeparation(40f); float[] ticksAtLevel2 = this.hTicks.GetTicksAtLevel(levelWithMinSeparation, false); for (int k = 0; k < ticksAtLevel2.Length; k++) { if (ticksAtLevel2[k] >= base.hRangeMin && ticksAtLevel2[k] <= base.hRangeMax) { int num4 = Mathf.RoundToInt(ticksAtLevel2[k] * frameRate); float num5 = Mathf.Floor(this.FrameToPixel((float)num4, frameRate, position)); string text = this.FormatTime(ticksAtLevel2[k], frameRate, timeFormat); GUI.Label(new Rect(num5 + 3f, -3f, 40f, 20f), text, TimeArea.styles.timelineTick); } } } GUI.EndGroup(); GUI.backgroundColor = backgroundColor; GUI.color = color; }