static string GetLabelForStandardFrameRate(StandardFrameRates option) { switch (option) { case StandardFrameRates.Fps23_97: return(L10n.Tr("Film NTSC: 23.97 fps")); case StandardFrameRates.Fps24: return(L10n.Tr("Film: 24 fps")); case StandardFrameRates.Fps25: return(L10n.Tr("PAL: 25 fps")); case StandardFrameRates.Fps29_97: return(L10n.Tr("NTSC: 29.97 fps")); case StandardFrameRates.Fps30: return(L10n.Tr("HD: 30 fps")); case StandardFrameRates.Fps50: return(L10n.Tr("Interlaced PAL: 50 fps")); case StandardFrameRates.Fps59_94: return(L10n.Tr("Interlaced NTSC: 59.94 fps")); case StandardFrameRates.Fps60: return(L10n.Tr("Game: 60 fps")); default: return(L10n.Tr("Custom")); } }
public static FrameRate ToFrameRate(StandardFrameRates enumValue) { switch (enumValue) { case StandardFrameRates.Fps23_97: return(FrameRate.k_23_976Fps); case StandardFrameRates.Fps24: return(FrameRate.k_24Fps); case StandardFrameRates.Fps25: return(FrameRate.k_25Fps); case StandardFrameRates.Fps29_97: return(FrameRate.k_29_97Fps); case StandardFrameRates.Fps30: return(FrameRate.k_30Fps); case StandardFrameRates.Fps50: return(FrameRate.k_50Fps); case StandardFrameRates.Fps59_94: return(FrameRate.k_59_94Fps); case StandardFrameRates.Fps60: return(FrameRate.k_60Fps); default: return(new FrameRate()); } ; }
/// <summary> /// Sets the EditorSetting frameRate to one of the provided standard frame rates. /// </summary> /// <param name="enumValue"> StandardFrameRates value, used to set the current EditorSettings frameRate value.</param> /// <remarks> /// When specifying drop frame values, it is recommended to select one of the provided standard frame rates. /// Specifying a non-standard custom frame rate may give incorrect results when playbackLockedToFrame /// is enabled during Timeline playback. /// </remarks> /// <exception cref="ArgumentException">Thrown when the enumValue is not a valid member of StandardFrameRates.</exception> /// <seealso cref="UnityEngine.Timeline.TimelineAsset"/> public void SetStandardFrameRate(StandardFrameRates enumValue) { FrameRate rate = TimeUtility.ToFrameRate(enumValue); if (rate.IsValid()) { throw new ArgumentException(String.Format("StandardFrameRates {0}, is not defined", enumValue.ToString())); } m_Framerate = rate.rate; }
internal static bool ToStandardFrameRate(FrameRate rate, out StandardFrameRates standard) { if (rate == FrameRate.k_23_976Fps) { standard = StandardFrameRates.Fps23_97; } else if (rate == FrameRate.k_24Fps) { standard = StandardFrameRates.Fps24; } else if (rate == FrameRate.k_25Fps) { standard = StandardFrameRates.Fps25; } else if (rate == FrameRate.k_30Fps) { standard = StandardFrameRates.Fps30; } else if (rate == FrameRate.k_29_97Fps) { standard = StandardFrameRates.Fps29_97; } else if (rate == FrameRate.k_50Fps) { standard = StandardFrameRates.Fps50; } else if (rate == FrameRate.k_59_94Fps) { standard = StandardFrameRates.Fps59_94; } else if (rate == FrameRate.k_60Fps) { standard = StandardFrameRates.Fps60; } else { standard = (StandardFrameRates)Enum.GetValues(typeof(StandardFrameRates)).Length; return(false); } return(true); }
public static string[] GetDefaultFrameRatesLabels(StandardFrameRates option) { string[] labels; if (s_FrameRateLabels == null || !s_FrameRateLabels.Any()) { var frameRates = (StandardFrameRates[])Enum.GetValues(typeof(StandardFrameRates)); labels = Array.ConvertAll(frameRates, GetLabelForStandardFrameRate); s_FrameRateLabels = labels; } else { labels = s_FrameRateLabels; } if (!Enum.IsDefined(typeof(StandardFrameRates), option)) { Array.Resize(ref labels, (int)option + 1); labels[(int)option] = GetLabelForStandardFrameRate(option); } return(labels); }
void AddStandardFrameRateMenu(GenericMenu menu, StandardFrameRates option, string label, bool on) { var gui = EditorGUIUtility.TextContent(String.Format(k_FrameRateMenuLabel, label)); if (state.editSequence.isReadOnly) { menu.AddDisabledItem(gui, on); return; } FrameRate value = TimeUtility.ToFrameRate(option); if (!value.IsValid()) { menu.AddItem(gui, true, () => { }); } else { menu.AddItem(gui, on, r => { state.editSequence.frameRate = (float)value.rate; }, value); } }
public static bool GetStandardFromFrameRate(double frameRate, out StandardFrameRates standard) { FrameRate frameRateObj = TimeUtility.GetClosestFrameRate(RoundFrameRate(frameRate)); return(TimeUtility.ToStandardFrameRate(frameRateObj, out standard)); }