помоги с рефакторингом 
using System;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;

namespace UI.SessionSettings.ChoosingQuest
{
    public class TimeInputField : MonoBehaviour
    {
        [SerializeField]
        private TMP_InputField inputField;

        private int hours;
        private int minutes;
        private string newValue;

        public event Action<int> OnChangeAmountTime;

        public void Initialize()
        {
            inputField.onValueChanged.AddListener(OnValueChanged);
        }

        public void Cleaning()
        {
            inputField.text = string.Empty;
        }

        private void OnValueChanged(string value)
        {
            if (!Regex.IsMatch(value, @"^\d *$"))
            {
                value = Regex.Replace(value, @"\D", "");
                newValue = value;
            }
            else
            {
                newValue = value;
            }

            if (newValue.Length == 2)
            {
                if (int.TryParse(newValue, out hours))
                {
                    if (hours > 24)
                    {
                        hours = 24;
                    }

                    inputField.text = string.Format("{0:D2} (ч) : ", hours);

                    OnChangeAmountTime?.Invoke(hours);

                    inputField.caretPosition = inputField.text.Length;

                    return;
                }
            }

            if (newValue.Length == 4)
            {
                string minutesStr = newValue.Substring(2, 2);

                if (int.TryParse(minutesStr, out minutes))
                {
                    if (minutes > 60)
                    {
                        int exceedingMinutes = minutes - 60;
                        int existingHours = 0;

                        if (inputField.text.Length >= 9)
                        {
                            string existingHoursStr = inputField.text.Substring(0, 2);
                            int.TryParse(existingHoursStr, out existingHours);
                        }

                        int newHours = existingHours + 1;
                        int newMinutes = exceedingMinutes;

                        if (newHours > 24)
                        {
                            newHours = 24;
                        }

                        string formattedValue = string.Format("{0:D2} (ч) : {1:D2} (мин)", newHours, newMinutes);
                        inputField.text = formattedValue;

                        OnChangeAmountTime?.Invoke(int.Parse(string.Format("{0:D2}{1:D2}", newHours, newMinutes)));

                        inputField.caretPosition = inputField.text.Length;

                        return;
                    }
                    else
                    {
                        string formattedValue = string.Format("{0:D2} (ч) : {1:D2} (мин)", hours, minutes);
                        inputField.text = formattedValue;

                        OnChangeAmountTime?.Invoke(int.Parse(string.Format("{0:D2}{1:D2}", hours, minutes)));

                        inputField.caretPosition = inputField.text.Length;

                        return;
                    }
                }
            }
        }
    }
}