public override void OnIncrement(bool fast)
        {
            if (m_Field.enumValues.Length == 0)
            {
                return;
            }

            var array = m_Field.enumValues;
            int index = m_Field.currentIndex;

            if (index == array.Length - 1)
            {
                index = 0;
            }
            else
            {
                if (fast)
                {
                    //check if quickSeparators have not been constructed
                    //it is the case when not constructed with autoenum
                    var separators = m_Field.quickSeparators;
                    if (separators == null)
                    {
                        m_Field.InitQuickSeparators();
                        separators = m_Field.quickSeparators;
                    }

                    int idxSup = 0;
                    for (; idxSup < separators.Length && index + 1 > separators[idxSup]; ++idxSup)
                    {
                        ;
                    }
                    if (idxSup == separators.Length)
                    {
                        index = 0;
                    }
                    else
                    {
                        index = separators[idxSup];
                    }
                }
                else
                {
                    index += 1;
                }
            }

            m_Field.SetValue(array[index]);
            m_Field.currentIndex = index;
            UpdateValueLabel();
        }
Пример #2
0
        /// <summary>
        /// On Enable method from <see cref="ScriptableObject"/>
        /// </summary>
        public override void OnEnable()
        {
            base.OnEnable();

            if (m_EnumField == null)
            {
                return;
            }

            m_EnumField.SetValue(value);
            base.SetValue(value, m_EnumField);
        }
        public override void OnIncrement(bool fast)
        {
            if (m_Field.enumValues.Length == 0)
            {
                return;
            }

            var array = m_Field.enumValues;
            int index = Array.IndexOf(array, m_Field.GetValue());

            if (index == array.Length - 1)
            {
                index = 0;
            }
            else
            {
                index += 1;
            }

            m_Field.SetValue(array[index]);
            UpdateValueLabel();
        }