{"id":18459373,"url":"https://github.com/juniordiscart/impossibleodds-popups","last_synced_at":"2026-05-19T19:32:30.670Z","repository":{"id":216015736,"uuid":"737795162","full_name":"juniordiscart/ImpossibleOdds-Popups","owner":"juniordiscart","description":"The Impossible Odds - Popups tool offers a simple and flexible way to display popups in different UI systems supported by Unity.","archived":false,"fork":false,"pushed_at":"2024-02-18T20:28:50.000Z","size":315,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T18:06:20.545Z","etag":null,"topics":["popups","unity","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juniordiscart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-01T14:30:01.000Z","updated_at":"2024-02-11T01:17:41.000Z","dependencies_parsed_at":"2024-01-14T15:54:58.942Z","dependency_job_id":"95c2ba9d-9f33-484e-93f1-c48ce1596d55","html_url":"https://github.com/juniordiscart/ImpossibleOdds-Popups","commit_stats":null,"previous_names":["juniordiscart/impossibleodds-popups"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/juniordiscart/ImpossibleOdds-Popups","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2FImpossibleOdds-Popups","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2FImpossibleOdds-Popups/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2FImpossibleOdds-Popups/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2FImpossibleOdds-Popups/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juniordiscart","download_url":"https://codeload.github.com/juniordiscart/ImpossibleOdds-Popups/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2FImpossibleOdds-Popups/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263844515,"owners_count":23518992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["popups","unity","unity3d"],"created_at":"2024-11-06T08:22:55.976Z","updated_at":"2026-05-19T19:32:20.651Z","avatar_url":"https://github.com/juniordiscart.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Impossible Odds Logo][Logo] Impossible Odds - Popups\n\nThe Impossible Odds - Popups package allows you to easily show popup messages in your Unity project. It works both in\nUnity's Canvas (Legacy UI and Text Mesh pro) and UI Toolkit systems.\n\n## Prerequisites \u0026 installation\n\nThis tool requires the [Impossible Odds - C# Toolkit](https://github.com/juniordiscart/ImpossibleOdds-Toolkit) to be\npresent in your project. You can add it to your project through Unity's package manager, by adding it as a git-managed\npackage using the following URL:\n\n\u003e https://github.com/juniordiscart/ImpossibleOdds-Toolkit.git?path=/Assets/Impossible%20Odds/Toolkit\n\nNext, add this popup tool using the same git-managed way to your project with the following URL:\n\n\u003e https://github.com/juniordiscart/ImpossibleOdds-Popups.git?path=/Assets/Impossible%20Odds/Popups\n\n## Setup\n\nTo start using the popup system, there's a simple scene setup involved. Depending on your preferred UI framework, drag\none of the following prefabs into your scene:\n\n* `LegacyPopupSystem` or `TMPPopupSystem` if you're using the Canvas UI system.\n* `UIToolkitPopupSystem` if you're using the UI Toolkit system.\n\nThat's it! You're ready to start showing popups on the screen.\n\nEach of these prefabs have some common traits:\n\n* They all have a 'popup display system' component that represents the specific implementation of the chosen UI\n  framework.\n* They all share a `Popup` component. This component acts as a singleton, so only one of them is allowed to be in the\n  scene.\n\n## Displaying popups\n\nTo start using the popup system in your project now, simply use the static `Popup` class from within your scripts.\nIt is found in the `ImpossibleOdds.Popups` namespace.\n\n`Popup` allows you to call forth two kinds of popups:\n\n### Simple popups\n\nA simple popup is a popup window with a single text message being displayed along with zero or more buttons for the\nuser to pick from. For each button, you can set the text and the action to perform when it's being clicked on.\n\nTo show a simple popup window on the screen, use the `ShowSimplePopup` method and provide it with a _description_ object\nof the popup.\n\n```C#\nPopup.ShowSimplePopup(new SimplePopupDescription()\n{\n    Header = \"Quit game?\",\n    Contents = \"Are you sure you want to quit the game?\\n\\nAny unsaved progress will be lost.\",\n    Buttons = new[]\n    {\n        new PopupButtonDescription()\n        {\n            text = \"Quit\",\n            onClickAction = Application.Quit\n        },\n        new PopupButtonDescription()\n        {\n            text = \"Cancel\"\n        }\n    }\n});\n```\n\n\u003cimg src=\"./Docs/Images/SimplePopup.png\" alt=\"drawing\" width=\"550\"/\u003e\n\nNote that you don't need to do anything for the popup to be dismissed if you provide it with a set of buttons. The popup\nsystem will hook itself into each of the provided buttons to close the popup window once clicked. However, if no\nbuttons are present, it's expected of the caller to close the popup using the provided handle through the `ClosePopup`\nmethod on the handle, or passing the handle to the popup system.\n\n### Custom popups\n\nCustom popup windows can be created as well. They require a little work and the required implementation details depend\non which display system (Canvas or UI Toolkit) you're using.\n\n* Unity's Canvas system: your popup should implement the `ImpossibleOdds.Popups.Canvas.ICustomPopupContents` interface.\n* UI Toolkit system: your popup should implement the `ImpossibleOdds.Popups.UIToolkit.ICustomPopupContents` interface.\n\nThese interfaces require you to define some common properties, and some that are specific to the display system being\nused. For example, the Canvas system requires an instantiated prefab so that is can be placed in the\nhierarchy of the Canvas and whether to destroy it after it has been closed, while the UI Toolkit one will require you to\nreturn a visual element that will be placed in the document tree.\n\nAn example of a custom popup in the Canvas system could look like this:\n\n```C#\npublic class CustomCanvasPopup : MonoBehaviour, ICustomPopupContents\n{\n    public event Action onClosePopup; \n    \n    [SerializeField]\n    private InputField inputField;\n    [SerializeField]\n    private Button buttonOk;\n    [SerializeField]\n    private Button buttonCancel;\n\n    public string Header =\u003e \"Who are you?\";\n    public bool DestroyAfterClose =\u003e true;\n    public RectTransform ContentsRoot =\u003e transform as RectTransform;\n\n    private void Start()\n    {\n        // Initialise the popup and hook up to the necessary events.\n    }\n}\n```\n\nThe same popup in the UI Toolkit system would look like this:\n\n```C#\npublic class CustomUITKPopup : ICustomPopupContents\n{\n    public event Action onClosePopup;\n\n    public string Header =\u003e \"Who are you?\";\n\n    public VisualElement ContentsRoot\n    {\n        get;\n    }\n\n    public CustomUITKPopup(VisualTreeAsset popupContentsAsset)\n    {\n        ContentsRoot = popupContentsAsset.Instantiate();\n        \n        // Query the contents, initialise the popup and hook up to the necessary events.\n    }\n}\n```\n\n\u003cimg src=\"./Docs/Images/CustomPopup.png\" alt=\"drawing\" width=\"550\"/\u003e\n\nSince you have full control over the contents of these custom popups, it's also up to you to call the necessary\n`onClosePopup` event when done, or call the `ClosePopup` method on the popup handle or on the static `Popup` class.\n\n## Customisation\n\nChances are you will want to change the look of the popup windows. Each kind of popup display system consists of a\ncouple of prefabs or objects. All assets used are found in the _Impossible Odds/Popups/Prefabs_ directories.\n\nBoth systems work with the same basic setup:\n\n```mermaid\n    graph TD;\n    A[Popup System] --\u003e B;\n    B[Popup Window] --\u003e C \u0026 D;\n    C[Header];\n    D[Contents];\n```\n\nThe popup display system will spawn and place the popup windows, and a popup window will have a header and contents.\nThe contents will depend on whether it's a simple or a custom popup.\n\n### Canvas\n\nCustomising the Canvas system can be done by adjusting the prefabs it works with, or create local copies of the prefabs\nand adjust them.\n\n### UI Toolkit\n\nThe UI Toolkit implementation has a document defined for each individual element, as well as a separate stylesheet.\nHowever, when integrating it in your existing project, make sure to set the correct panel settings to make the visual\nelements receive the correct styling and events.\n\n## Unity Version\n\nDeveloped and tested on Unity 2021.3 LTS.\n\n## License\n\nThis package is provided under the [MIT][License] license.\n\n[License]: ./LICENSE.md\n\n[Logo]: ./Docs/Images/ImpossibleOddsLogo.png","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniordiscart%2Fimpossibleodds-popups","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuniordiscart%2Fimpossibleodds-popups","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniordiscart%2Fimpossibleodds-popups/lists"}