public static double FrameRateField(double frameRate, GUIContent label, Rect position, out bool isValid)
        {
            double    frameRateDouble = FrameRateDisplayUtility.RoundFrameRate(frameRate);
            FrameRate frameRateObj    = TimeUtility.GetClosestFrameRate(frameRateDouble);

            isValid = frameRateObj.IsValid();
            TimeUtility.ToStandardFrameRate(frameRateObj, out StandardFrameRates option);

            position = EditorGUI.PrefixLabel(position, label);
            Rect posPopup      = new Rect(position.x, position.y, position.width / 2, position.height);
            Rect posFloatField = new Rect(posPopup.xMax, position.y, position.width / 2, position.height);

            using (var checkOption = new EditorGUI.ChangeCheckScope())
            {
                option = (StandardFrameRates)EditorGUI.Popup(posPopup, (int)option,
                                                             FrameRateDisplayUtility.GetDefaultFrameRatesLabels(option));

                if (checkOption.changed)
                {
                    isValid = true;
                    return(TimeUtility.ToFrameRate(option).rate);
                }
            }

            using (var checkFrame = new EditorGUI.ChangeCheckScope())
            {
                frameRateDouble = Math.Abs(EditorGUI.DoubleField(posFloatField, frameRateDouble));
                frameRateObj    = TimeUtility.GetClosestFrameRate(frameRateDouble);
                if (checkFrame.changed)
                {
                    isValid = frameRateObj.IsValid();
                    return(isValid ? frameRateObj.rate : frameRateDouble);
                }
            }

            return(frameRateDouble);
        }
예제 #2
0
        public static bool GetStandardFromFrameRate(double frameRate, out StandardFrameRates standard)
        {
            FrameRate frameRateObj = TimeUtility.GetClosestFrameRate(RoundFrameRate(frameRate));

            return(TimeUtility.ToStandardFrameRate(frameRateObj, out standard));
        }