tomazsaraiva / unity-canvas-page-slider

A Scrollable Page Viewer for Unity
https://tomazsaraiva.github.io/unity-canvas-page-slider/
28 stars 2 forks source link

For Your Information: Navigation Button support #7

Open jpetays opened 3 months ago

jpetays commented 3 months ago

This is only for your information and might be a possible feature for navigation menu system if you see it fit. If this is possible to do right now without any (or minimal) coding it would be nice to have an example how to do it.

I'm developing a quite typical mobile game that has three navigation buttons at the bottom of the screen. I'm not familiar how UnityEvent based communication between component is intended to work or what use cases they have. Maybe it is for more UNITY Inspector oriented workflows? So it might be that button based navigation could be achieved already, but as there are no examples I don't have any clue.

        /// <summary>
        /// UnityEvent with an integer parameter that is invoked when the dot is pressed.
        /// The parameter represents the index of the pressed dot.
        /// </summary>
        [Tooltip("Invoked when the dot is pressed with it's index")]
        public UnityEvent<int> OnPressed;

So I added my own Navigation Button support to PageDot. And for this reason I need to have animated transitions on PageScroller.SetPage().

        /// <summary>
        /// Determines whether it should reflect 'dot' state changes to Image or Button component.
        /// </summary>
        [Header("Configuration")]
        [Tooltip("Determines whether it should change the Image component color on 'dot' state changes")]
        [SerializeField] private bool _useImageComponent;

        [Tooltip("Determines whether it should change the Button component interactable state on 'dot' state changes")]
        [SerializeField] private bool _useButtonComponent;

PageDot.cs.txt

Current design that has not yet been implemented. But the new PageDot.cs should be able to handle it. 2024-08-03_w_3229

tomazsaraiva commented 3 months ago

I had that feature in mind, but it ended up being half-done. The PageDot has the events set up, but nothing is triggering them. I’ll fix it.