Skip to content

Code suggestion #2

@Stader

Description

@Stader

To increase customization, I'd like to suggest a change to the currentType:

public int currentType
        {
            get => _currentType;

            set
            {
                if (value > maxType) _currentType = 0;
                else if(value < 0)_currentType = maxType;
                else _currentType = value;
            }
        }

So we can go back and forth in the array.

I also incremented a change in InitChange and created its variation to return.

public void InitChangeAdd()
        {
            if (volumes == null) return;
            
            currentType++;
            
            PlayerPrefs.SetInt("Accessibility.ColorblindType", currentType);

            StartCoroutine(ApplyFilter());
            
#if UNITY_EDITOR
            // TODO: Use a public event system to announce the change of the activated filter
            Debug.Log($"Color changed to <b>{(ColorblindTypes)currentType} {currentType}</b>/{maxType}");
#endif
        }

        public void InitChangeRemove()
        {
            if (volumes == null) return;
            
            currentType--;

            PlayerPrefs.SetInt("Accessibility.ColorblindType", currentType);

            StartCoroutine(ApplyFilter());
            
#if UNITY_EDITOR
            // TODO: Use a public event system to announce the change of the activated filter
            Debug.Log($"Color changed to <b>{(ColorblindTypes)currentType} {currentType}</b>/{maxType}");
#endif
        }

There is a way to simplify this in just one method, but for a while I ended up not doing it.

Thank you for developing this solution for color blindness!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions