{"id":25995029,"url":"https://github.com/hashiiiii/rectpop","last_synced_at":"2025-10-15T12:04:24.196Z","repository":{"id":270790280,"uuid":"908080553","full_name":"hashiiiii/RectPop","owner":"hashiiiii","description":"A Unity plugin for positioning layouts around a RectTransform using anchors and pivots.","archived":false,"fork":false,"pushed_at":"2025-02-09T04:01:00.000Z","size":2288,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T09:13:54.826Z","etag":null,"topics":["csharp","game","ugui","ui","unity"],"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/hashiiiii.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-12-25T04:33:48.000Z","updated_at":"2025-02-17T09:54:17.000Z","dependencies_parsed_at":"2025-01-03T05:29:22.055Z","dependency_job_id":"cff4fdf1-134b-41bb-bc7b-71539017dcc4","html_url":"https://github.com/hashiiiii/RectPop","commit_stats":null,"previous_names":["hashiiiii/rectpop"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashiiiii%2FRectPop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashiiiii%2FRectPop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashiiiii%2FRectPop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashiiiii%2FRectPop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hashiiiii","download_url":"https://codeload.github.com/hashiiiii/RectPop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashiiiii%2FRectPop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259144813,"owners_count":22811926,"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":["csharp","game","ugui","ui","unity"],"created_at":"2025-03-05T15:18:20.102Z","updated_at":"2025-10-15T12:04:19.160Z","avatar_url":"https://github.com/hashiiiii.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=600 src=\"Documentation/Images/logo.png\" alt=\"RectPop\"\u003e\n\u003c/p\u003e\n\n# RectPop\n\n[![license](https://img.shields.io/badge/LICENSE-MIT-green.svg)](LICENSE.md)\n\n**Documentation ( [English](README.md), [Japanese](README_JA.md) )**\n\nRectPop provides features to develop floating UIs such as popovers, tooltips, context menus, and more, **easily and efficiently**.\n\nRectPop lowers the barrier to standardize floating UIs, helping to prevent similar-looking prefabs from being implemented multiple times throughout a project.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/top.gif\" alt=\"ConceptMovie\"\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\u003c!-- param::title::Details:: --\u003e\n\u003cdetails\u003e\n\u003csummary\u003eDetails\u003c/summary\u003e\n\n- [Overview](#overview)\n- [Features](#features)\n  - [Easy Standardization of Floating UIs](#easy-standardization-of-floating-uis)\n  - [Placing the UI Within the Render Area](#placing-the-ui-within-the-render-area)\n  - [Supports All RenderModes](#supports-all-rendermodes)\n  - [Floating Options](#floating-options)\n    - [Mode](#mode)\n    - [Offset](#offset)\n  - [Support for Multiple Resolutions](#support-for-multiple-resolutions)\n- [Setup](#setup)\n  - [Installation](#installation)\n- [Minimal Usage](#minimal-usage)\n- [Recommended Usage](#recommended-usage)\n  - [R3, UniRx](#r3-unirx)\n- [License](#license)\n\n\u003c/details\u003e\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Overview\n\nWhen you make a request to RectPop’s core system with any object that has a RectTransform and the Canvas on which that object is placed, it returns the settings necessary for displaying a floating UI. By using RectPop’s UI modules, you can easily apply this result to the UI.\n\nFurthermore, as shown in the initial GIF, the system provides a feature that **allows you to reuse a single floating UI in multiple places**. RectPop’s UI modules **keep the request context and the result context loosely coupled**.\n\n## Features\n\n### Easy Standardization of Floating UIs\n\nAs mentioned above, RectPop’s calculation logic does not demand anything more than:\n\n1. Any object that has a `RectTransform`\n2. The `Canvas` in which that object is placed\n\nFurthermore, there are no constraints between the floating UI and the base object, making it possible to use a single floating UI and send requests from various objects.\n\nRectPop also provides the mechanism for this. For an implementation example, refer to Example02Request.cs and Example02Result.cs.\n\n### Placing the UI Within the Render Area\n\nThe response contains settings for Pivot and Anchor. By applying these to the floating UI, in most cases the UI will remain on-screen.\n\n\u003e [!WARNING]\n\u003e If the floating UI is excessively large or you apply extreme offsets, it may end up going off-screen.\n\nMethods needed for applying these settings are also provided. See the Apply method in PopHandler.cs.\n\n### Supports All RenderModes\n\nThere are three `Canvas.RenderMode` values: `ScreenSpaceOverlay`, `ScreenSpaceCamera`, and `WorldSpace`. RectPop supports all of them.\n\n### Floating Options\n\n#### Mode\n\nThere are three modes:\n\n\u003e [!NOTE]\n\u003e You can change the floating position from the default.  \n\u003e Override PopProvider.GetPopAnchorWorldPoint and PopProvider.GetPopPivotPosition in a class that inherits from PopProvider.\n\n1. Inside  \n   Floats inside the object.\n\n   \u003cp align=\"center\"\u003e\n     \u003cimg width=\"50%\" src=\"Documentation/Images/inside.png\" alt=\"Inside\"\u003e\n   \u003c/p\u003e\n\n2. OutsideVertical  \n   Floats above or below the object.\n\n   \u003cp align=\"center\"\u003e\n     \u003cimg width=\"50%\" src=\"Documentation/Images/outside_vertical.png\" alt=\"OutsideVertical\"\u003e\n   \u003c/p\u003e\n\n3. OutsideHorizontal  \n   Floats to the left or right of the object.\n\n   \u003cp align=\"center\"\u003e\n     \u003cimg width=\"50%\" src=\"Documentation/Images/outside_horizontal.png\" alt=\"OutsideHorizontal\"\u003e\n   \u003c/p\u003e\n\n#### Offset\n\nYou can add offsets to the top, bottom, left, and right.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/offset.gif\" alt=\"ConceptMovie\"\u003e\n\u003c/p\u003e\n\n### Support for Multiple Resolutions\n\nAs shown in the initial [GIF](#rectpop), RectPop calculates results based on the screen resolution. This means you can support any resolution and, in cases where the resolution changes dynamically, recalculating will display the floating UI in the correct position.\n\n## Setup\n\n### Installation\n\nYou can install RectPop via the Unity Package Manager.\n\n1. Open Unity and select `Window` \u003e `Package Manager`.\n2. Click the `+` button in the top-left corner and choose `Add package from git URL...`.\n3. Enter the following URL: `https://github.com/hashiiiii/RectPop.git?path=/Assets/RectPop/Sources#v2.0.1`\n4. Click `Add` to install the package.\n\nFor more details, see the Unity manual on “Installing from a Git URL”.\n\n## Minimal Usage\n\n\u003e [!NOTE]  \n\u003e There is an example in `Assets/RectPop/Examples/Example01.unity`. Please refer to it as needed.\n\n1. Create a Canvas and an object that has a `RectTransform.`\n\n   In the Unity Editor, prepare the `Canvas` that will be the base for your floating UI, and also the `RectTransform` object.\n\n2. Obtain a `PopHandler` instance.\n\n   `PopHandler` is a handler for the calculation logic (`IPopProvider`).\n\n    ```csharp\n    public class Example01 : MonoBehaviour\n    {\n        private readonly PopHandler _handler = new();\n    }\n    ```\n\n   `PopHandler` requires an `IPopProvider`. The default constructor uses a `PopProvider`. In most cases, this will suffice.\n\n    ```csharp\n    public class PopHandler\n    {\n        // static\n        private static readonly IPopProvider Default = new PopProvider();\n      \n        // dependency\n        private readonly IPopProvider _provider;\n      \n        // constructor\n        public PopHandler(IPopProvider provider)\n        {\n            _provider = provider;\n        }\n      \n        public PopHandler() : this(Default)\n        {\n        }\n    \n        // ----- code omitted -----\n    }\n    ```\n\n\u003e [!NOTE]\n\u003e If you don’t need to handle multiple `IPopProvider` instances simultaneously, you could also treat the `PopHandler` instance as a singleton.\n\n3. Execute `PopHandler.Request`, `PopHelper.Apply`.\n\n   In this example, we display the floating UI when the button is clicked.\n\n    ```csharp\n    public class Example01 : MonoBehaviour\n    {\n        // base\n        [SerializeField] private Canvas _baseCanvas;\n        [SerializeField] private Button _button;\n    \n        // floating ui\n        [SerializeField] private RectTransform _popRect;\n        [SerializeField] private Canvas _popCanvas;\n    \n        private readonly PopHandler _handler = new();\n    \n        private void Awake()\n        {\n            _button.onClick.AddListener(() =\u003e\n            {\n                // get base rect transform\n                var baseRectTransform = _button.GetComponent\u003cRectTransform\u003e();\n    \n                // create request\n                var request = new PopRequest(baseRectTransform, _baseCanvas);\n    \n                // send request and apply result to floating ui\n                var result = _handler.Request(request);\n                PopHelper.Apply(result, _popRect, _popCanvas);\n    \n                // show floating ui\n                _popRect.gameObject.SetActive(true);\n            });\n        }\n    }\n    ```\n\n## Recommended Usage\n\nIn the Minimal Usage example, the base UI and the floating UI were both referenced within the same file. However, in reality, you will likely want to reuse a single floating UI in multiple places. Below is a recommended approach for such a scenario, separating each part into different files.\n\n\u003e [!NOTE]\n\u003e There is an example in `Assets/RectPop/Examples/Example02.unity`. Please refer to it as needed.\n\n1. Refer to steps 1 and 2 in Minimal Usage.\n\n   These steps are the same.\n\n2. Execute `PopHandler.Request`.\n\n   This is almost the same implementation as step 3 of [Minimal Usage](#minimal-usage). The difference is that we delegate the process of displaying the floating UI to another class, making this class more concise.\n\n    ```csharp\n   public class Example02Request : MonoBehaviour\n   {\n       // base\n       [SerializeField] private Canvas _baseCanvas;\n       [SerializeField] private Button _button;\n\n       private readonly PopHandler _handler = new();\n\n       private void Awake()\n       {\n           _button.onClick.AddListener(() =\u003e\n           {\n               // get base rect transform\n               var baseRectTransform = _button.GetComponent\u003cRectTransform\u003e();\n\n               // create request\n               var request = new PopRequest(baseRectTransform, _baseCanvas);\n\n               // send request\n               _handler.Request(request);\n           });\n       }\n   }\n   ```\n\n3. Execute `PopHelper.Apply`.\n\n   Here, we create a class that actually displays the floating UI. We subscribe to the `PopDispatcher.OnDispatched` event to receive the result and then display it.\n\n    ```csharp\n   public class Example02Result : MonoBehaviour\n   {\n       // floating ui\n       [SerializeField] private RectTransform _floatingRect;\n       [SerializeField] private Canvas _floatingCanvas;\n\n       // register event\n       private void Awake()\n       {\n           PopDispatcher.OnDispatched += OnPopDispatched;\n       }\n\n       // unregister event\n       private void OnDestroy()\n       {\n           PopDispatcher.OnDispatched -= OnPopDispatched;\n       }\n\n       // apply result to floating ui\n       private void OnPopDispatched(PopDispatchedEvent ev)\n       {\n           PopHelper.Apply(ev.Result, _floatingRect, _floatingCanvas);\n           _floatingRect.gameObject.SetActive(true);\n       }\n   }\n   ```\n\n### R3, UniRx\n\nRectPop provides integrations so that you can more easily perform event-driven programming with the following OSS:\n\n- R3 (https://github.com/Cysharp/R3)\n- UniRx (https://github.com/neuecc/UniRx)\n\n\u003e [!NOTE]\n\u003e There are examples in `Assets/RectPop/Examples/Example02ForR3.unity`, `Assets/RectPop/Examples/Example02ForUniRx.unity`. Please refer to it as needed.\n\n## License\n\nThis software is released under the MIT License.  \nYou are free to use it within the scope of the license, but you must include the following copyright notice and license text when using this software:\n\n* [LICENSE.md](LICENSE.md)\n\nAdditionally, the table of contents in this document was generated using the following software:\n\n* toc-generator (https://github.com/technote-space/toc-generator)\n\nFor details on the toc-generator license, please see [Third Party Notices.md](Third%20Party%20Notices.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashiiiii%2Frectpop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashiiiii%2Frectpop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashiiiii%2Frectpop/lists"}