Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gilzoide/unity-back-button-stack
Easily manage a stack of objects that respond to the ESC button / Android Back button in Unity, so that only the top object handles the event.
https://github.com/gilzoide/unity-back-button-stack
back-button backbutton manager stack unity unity3d upm upm-package
Last synced: 1 day ago
JSON representation
Easily manage a stack of objects that respond to the ESC button / Android Back button in Unity, so that only the top object handles the event.
- Host: GitHub
- URL: https://github.com/gilzoide/unity-back-button-stack
- Owner: gilzoide
- License: unlicense
- Created: 2023-10-28T02:55:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-01-10T12:05:05.000Z (9 months ago)
- Last Synced: 2024-09-23T11:32:36.913Z (2 days ago)
- Topics: back-button, backbutton, manager, stack, unity, unity3d, upm, upm-package
- Language: C#
- Homepage:
- Size: 22.5 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Back Button Stack
[![openupm](https://img.shields.io/npm/v/com.gilzoide.back-button-stack?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.gilzoide.back-button-stack/)Easily manage a stack of objects that respond to the ESC button / Android Back button in Unity, so that only the top object handles the event.
Check out the [Popup Stack](Samples~/PopupStack) sample scene for some usage example.
## Features
- Only the last object in the stack will be called when the ESC/Back button is pressed.
- Inherit [ABackButtonHandler](Runtime/ABackButtonHandler.cs) to have scripts that handle the ESC/Back button be inserted/removed from the singleton stack automatically in their `OnEnable` / `OnDisable` methods.
- Supports pure C# classes as well, just implement the [IBackButtonHandler](Runtime/IBackButtonHandler.cs) interface and call `AddToBackButtonStack` and `RemoveFromBackButtonStack` to add / remove it from the singleton stack.
- Custom inspector for debugging which objects are currently in the stack, just select the `BackButtonStack` object in the `DontDestroyOnLoad` scene while in Play Mode.## How to install
Either:
- Use the [openupm registry](https://openupm.com/) and install this package using the [openupm-cli](https://github.com/openupm/openupm-cli):
```
openupm add com.gilzoide.back-button-stack
```
- Install using the [Unity Package Manager](https://docs.unity3d.com/Manual/upm-ui-giturl.html) with the following URL:
```
https://github.com/gilzoide/unity-back-button-stack.git#1.0.0-preview1
```
- Clone this repository or download a snapshot of it directly inside your project's `Assets` or `Packages` folder.