예제 #1
0
        public static ClampedIntDrawer Create(int value, int min, int max, LinkedMemberInfo memberInfo, IParentDrawer parent, GUIContent label, bool setReadOnly)
        {
            ClampedIntDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new ClampedIntDrawer();
            }
            result.Setup(value, min, max, memberInfo, parent, label, setReadOnly);
            result.LateSetup();
            return(result);
        }
예제 #2
0
        /// <inheritdoc />
        protected override void DoBuildMembers()
        {
            bool readOnly = memberInfo != null && !memberInfo.CanWrite;

            if (readOnly)
            {
                DrawerArrayPool.Resize(ref members, 0);
            }
            else
            {
                DrawerArrayPool.Resize(ref members, 2);

                var min = TimeSpan.MinValue;
                var max = TimeSpan.MaxValue;

                var group = CustomDataSetDrawer.Create(this, GUIContentPool.Create("Days / Hours"), ReadOnly);
                {
                    var groupMembers = DrawerArrayPool.Create(2);

                    var groupMember = ClampedIntDrawer.Create(Days, min.Days, max.Days, null, group, GUIContentPool.Create("D"), ReadOnly);
                    groupMember.OnValueChanged += SetDays;
                    groupMembers[0]             = groupMember;

                    groupMember = ClampedIntDrawer.Create(Hours, MinHours, MaxHours, null, group, GUIContentPool.Create("H"), ReadOnly);
                    groupMember.OnValueChanged       += SetHours;
                    groupMember.OverrideValidateValue = ValidateHours;
                    groupMembers[1] = groupMember;

                    group.SetMembers(groupMembers, true);
                    members[0] = group;
                }

                group = CustomDataSetDrawer.Create(this, GUIContentPool.Create("Minutes / Seconds"), ReadOnly);
                {
                    var groupMembers = DrawerArrayPool.Create(2);

                    var groupMember = ClampedIntDrawer.Create(Minutes, MinMinutes, MaxMinutes, null, group, GUIContentPool.Create("M"), ReadOnly);
                    groupMember.OnValueChanged       += SetMinutes;
                    groupMember.OverrideValidateValue = ValidateMinutes;
                    groupMembers[0] = groupMember;

                    var secondsMember = ClampedFloatDrawer.Create(SecondsWithFractions, MinSeconds, MaxSeconds, null, group, GUIContentPool.Create("S"), ReadOnly);
                    secondsMember.OnValueChanged       += SetSeconds;
                    secondsMember.OverrideValidateValue = ValidateSeconds;
                    groupMembers[1] = secondsMember;

                    group.SetMembers(groupMembers, true);
                    members[1] = group;
                }
            }
        }
예제 #3
0
        /// <inheritdoc />
        protected override void DoBuildMembers()
        {
            if (ReadOnly)
            {
                DrawerArrayPool.Resize(ref members, 0);
            }
            else
            {
                DrawerArrayPool.Resize(ref members, 2);

                var value = Value;
                asString = StringUtils.TimeToString(value);
                int   year   = value.Year;
                int   month  = value.Month;
                int   day    = value.Day;
                int   hour   = value.Hour;
                int   minute = value.Minute;
                float second = value.Second + value.Millisecond * 0.001f;

                var min = DateTime.MinValue;
                var max = DateTime.MaxValue;

                var group = CustomDataSetDrawer.Create(this, GUIContentPool.Create("Date"), false);
                {
                    var groupMembers = DrawerArrayPool.Create(3);

                    var groupMember = ClampedIntDrawer.Create(year, min.Year, max.Year, null, group, GUIContentPool.Create("Y"), false);
                    groupMember.OnValueChanged       += SetYear;
                    groupMember.OverrideValidateValue = ValidateYear;
                    groupMember.overrideReset         = ResetToOne;
                    groupMembers[YearMemberIndex]     = groupMember;

                    groupMember = ClampedIntDrawer.Create(month, min.Month, max.Month, null, group, GUIContentPool.Create("M"), false);
                    groupMember.OnValueChanged       += SetMonth;
                    groupMember.OverrideValidateValue = ValidateMonth;
                    groupMember.overrideReset         = ResetToOne;
                    groupMembers[MonthMemberIndex]    = groupMember;

                    groupMember = ClampedIntDrawer.Create(day, min.Day, max.Day, null, group, GUIContentPool.Create("D"), false);
                    groupMember.OnValueChanged       += SetDay;
                    groupMember.OverrideValidateValue = ValidateDay;
                    groupMember.overrideReset         = ResetToOne;
                    groupMembers[DayMemberIndex]      = groupMember;

                    group.SetMembers(groupMembers, true);
                    members[0] = group;
                }

                group = CustomDataSetDrawer.Create(this, GUIContentPool.Create("Time"), false);
                {
                    var groupMembers = DrawerArrayPool.Create(3);

                    var groupMember = ClampedIntDrawer.Create(hour, 0, 23, null, group, GUIContentPool.Create("H"), false);
                    groupMember.OnValueChanged       += SetHour;
                    groupMember.OverrideValidateValue = ValidateHour;
                    groupMembers[HourMemberIndex]     = groupMember;

                    groupMember = ClampedIntDrawer.Create(minute, 0, 59, null, group, GUIContentPool.Create("M"), false);
                    groupMember.OnValueChanged       += SetMinute;
                    groupMember.OverrideValidateValue = ValidateMinute;
                    groupMembers[MinuteMemberIndex]   = groupMember;

                    var secondsMember = ClampedFloatDrawer.Create(second, 0f, 60f - float.Epsilon, null, group, GUIContentPool.Create("S"), false);
                    secondsMember.OnValueChanged       += SetSeconds;
                    secondsMember.OverrideValidateValue = ValidateSecond;
                    groupMembers[SecondMemberIndex]     = secondsMember;

                    group.SetMembers(groupMembers, true);
                    members[1] = group;
                }
            }
        }