How hashiiiii/rectpop works
Main Components
• UI Request Component: Represents the Unity UI element (or code component) that triggers the floating UI. In the examples, these are represented by scripts like Example01 and Example02Request.
• PopHandler: Acts as the core coordinator. It receives a PopRequest (built from a RectTransform and Canvas) and delegates the processing.
• IPopProvider (and its default implementation, PopProvider): Responsible for calculating the correct settings for the floating UI. This includes determining positions and handling any offset or mode (Inside, OutsideVertical, OutsideHorizontal) adjustments.
• PopHelper: A utility that takes the computed results from PopHandler/IPopProvider and applies them to the UI’s RectTransform, ensuring the floating UI is positioned correctly.
• PopDispatcher: Implements an event-driven system to broadcast the result of a pop request (via PopDispatchedEvent) so that the floating UI can update appropriately. It also supports integration with event libraries.
• Integration Modules: Optional integrations with external event-driven frameworks, such as R3 and UniRx, which are demonstrated by separate example projects.
Out the Relationships and Interactions
• When a UI element (such as a button) is interacted with, its associated script creates a PopRequest (using its RectTransform and Canvas).
• This request is then sent to a PopHandler instance.
• The PopHandler calls the appropriate IPopProvider (or the default PopProvider) to calculate the correct floating UI settings based on the request.
• The computed result is either directly applied using PopHelper (as in the minimal usage example) or dispatched via PopDispatcher (as shown in the recommended usage example) to be handled asynchronously.
• The attached listener for the dispatched event then receives the PopDispatchedEvent and uses PopHelper to apply the settings to the floating UI’s RectTransform.
Important Architectural Patterns
• The package embraces a request/response design (through PopRequest and PopDispatchedEvent) that loosely couples the UI trigger from the display logic.
• There is a clear separation of concerns: PopHandler coordinates, IPopProvider calculates positioning, and PopHelper applies the UI changes.
• The use of events (via PopDispatcher) to decouple the population of results supports scalability and integration with reactive programming models (e.g., R3 and UniRx).
Relevant Technologies and Frameworks
• Unity’s UI system (using RectTransform, Canvas, Unity’s event system, etc.).
• The internal scripting architecture of RectPop (PopHandler, PopProvider, PopHelper, PopDispatcher).
• Optional libraries: R3 and UniRx for event-driven programming.
• Git-based package installation via Unity Package Manager.
Instructing the Principal Software Engineer to Include the Following
• Nodes for:
• UI Request (e.g., the Unity Button or any script initiating a PopRequest)
• PopHandler (the central orchestrator)
• IPopProvider / PopProvider (calculates floating UI parameters)
• PopDispatcher (event bus mechanism for broadcast, if used)
• PopHelper (utility for applying the computed settings)
• External Libraries (R3 / UniRx integrations) – you might indicate these with a separated or differently styled node.
• Start from UI Request → PopHandler → IPopProvider → (result dispatch via PopDispatcher) → PopHelper → Final UI update.
• A third for the UI client code and examples that trigger the logic.
• Optionally, if space permits, add sub-notes that detail key methods (like PopHandler.Request and PopHelper.Apply) or mention that the IPopProvider offers customizable behavior (via method overrides such as for GetPopAnchorWorldPoint and GetPopPivotPosition).