popup changes

This commit is contained in:
Sebastian Bularca
2026-04-06 10:44:16 +02:00
parent 61ca3701ae
commit cbf9f384d9
39 changed files with 1222 additions and 45 deletions

View File

@@ -4,7 +4,7 @@
**Goal:** Build `com.jovian.popup-system`, a low-allocation popup/tooltip package with category-based isolation, fluent content builder, grow-only element cache, screen edge clamping, and extensible animations.
**Architecture:** Per-game-state `IPopupSystem` instances with registered categories. Each category lazily creates one `PopupView` MonoBehaviour that reuses cached content elements. `PopupTrigger` MonoBehaviour handles hover detection. `PopupContentBuilder` struct operates directly on cached elements. Float-based timers in `Tick()` — no coroutines.
**Architecture:** Per-game-state `IPopupSystem` instances with registered categories. Each category lazily creates one `PopupReference` MonoBehaviour that reuses cached content elements. `PopupTrigger` MonoBehaviour handles hover detection. `PopupContentBuilder` struct operates directly on cached elements. Float-based timers in `Tick()` — no coroutines.
**Tech Stack:** Unity 6 / C# 9, TextMeshPro, Unity Input System, Newtonsoft.Json
@@ -373,12 +373,12 @@ git commit -m "feat: add IPopupAnimator interface and FadePopupAnimator"
---
### Task 5: PopupView MonoBehaviour with element cache
### Task 5: PopupReference MonoBehaviour with element cache
**Files:**
- Create: `Packages/com.jovian.popup-system/Runtime/UI/PopupView.cs`
- Create: `Packages/com.jovian.popup-system/Runtime/UI/PopupReference.cs`
**Step 1: Implement PopupView with grow-only element cache, positioning, and screen clamping**
**Step 1: Implement PopupReference with grow-only element cache, positioning, and screen clamping**
```csharp
using System.Collections.Generic;
@@ -388,7 +388,7 @@ using UnityEngine.InputSystem;
using UnityEngine.UI;
namespace Jovian.PopupSystem.UI {
public class PopupView : MonoBehaviour {
public class PopupReference : MonoBehaviour {
[SerializeField] RectTransform content;
[SerializeField] CanvasGroup canvasGroup;
[SerializeField] RectTransform background;
@@ -563,8 +563,8 @@ namespace Jovian.PopupSystem.UI {
**Step 2: Commit**
```bash
git add Packages/com.jovian.popup-system/Runtime/UI/PopupView.cs
git commit -m "feat: add PopupView with grow-only element cache and positioning"
git add Packages/com.jovian.popup-system/Runtime/UI/PopupReference.cs
git commit -m "feat: add PopupReference with grow-only element cache and positioning"
```
---
@@ -582,9 +582,9 @@ using UnityEngine;
namespace Jovian.PopupSystem {
public struct PopupContentBuilder {
readonly PopupView view;
readonly PopupReference view;
public PopupContentBuilder(PopupView view) {
public PopupContentBuilder(PopupReference view) {
this.view = view;
}
@@ -685,11 +685,11 @@ using Object = UnityEngine.Object;
namespace Jovian.PopupSystem {
public sealed class PopupSystem : IPopupSystem {
readonly PopupSettings settings;
readonly PopupView viewPrefab;
readonly PopupReference viewPrefab;
readonly IPopupAnimator animator;
readonly Dictionary<PopupCategory, ViewState> categories = new();
public PopupSystem(PopupSettings settings, PopupView viewPrefab, IPopupAnimator animator = null) {
public PopupSystem(PopupSettings settings, PopupReference viewPrefab, IPopupAnimator animator = null) {
this.settings = settings;
this.viewPrefab = viewPrefab;
this.animator = animator ?? new FadePopupAnimator();
@@ -847,7 +847,7 @@ namespace Jovian.PopupSystem {
}
private sealed class ViewState {
public PopupView view;
public PopupReference view;
public int priority;
public float delay;
public float delayTimer;
@@ -993,7 +993,7 @@ git commit -m "feat: add PopupSettingsProvider for Project Settings"
| `Packages/com.jovian.popup-system/Runtime/PopupContentBuilder.cs` | Create | Fluent builder struct |
| `Packages/com.jovian.popup-system/Runtime/IPopupSystem.cs` | Create | System interface |
| `Packages/com.jovian.popup-system/Runtime/PopupSystem.cs` | Create | System implementation |
| `Packages/com.jovian.popup-system/Runtime/UI/PopupView.cs` | Create | MonoBehaviour with element cache |
| `Packages/com.jovian.popup-system/Runtime/UI/PopupReference.cs` | Create | MonoBehaviour with element cache |
| `Packages/com.jovian.popup-system/Runtime/UI/PopupTrigger.cs` | Create | Hover trigger MonoBehaviour |
| `Packages/com.jovian.popup-system/README.md` | Create | Package documentation |
| `Packages/com.jovian.popup-system/Editor/PopupSettingsProvider.cs` | Create | Project Settings UI |