Unity uses stack to realize sliding page turning effect

Unity uses stack data structure and animation controller to realize sliding page turning effect, and supports keyboard control and touch screen sliding control (including control script, which can customize input).
The effect is as follows:
Effect picture of sliding page
Part of the code is as follows:

//达到最后一页,停止左滑
            if (GameState.pageNumberOfTheme < 5)
            {
    
    
                GameObject previousPage = (GameObject)centerStack.Pop();
                leftStack.Push(previousPage);
                previousPage.GetComponent<Animator>().SetBool("CenterToLeft", true);
                GameObject nextPage = (GameObject)rightStack.Pop();
                centerStack.Push(nextPage);
                nextPage.GetComponent<Animator>().SetBool("RightToCenter", true);
                GameState.pageNumberOfTheme += 1;

                GameState.fingersUp = false;
            }

Source code link:
Swipe to turn pages - Unity project source code

Guess you like

Origin blog.csdn.net/qq_40364278/article/details/127410380