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

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 608491ce009b2494c894080b243698b9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e663435ad13b46d40a29802dab7e52f5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 63a03b88ed78a934094ce61f9d127ec9

View File

@@ -17,7 +17,7 @@ Install via the Unity Package Manager by adding the package from its local path
In the Unity Editor, go to **Assets > Create > Jovian > Popup System > Popup Settings**. Place the asset somewhere accessible (e.g. `Assets/Settings/PopupSettings.asset`). You can also configure settings via **Project Settings > Jovian > Popup System**.
### 2. Build a PopupView prefab
### 2. Build a PopupReference prefab
See the [Prefab Setup](#prefab-setup) section below for step-by-step instructions.
@@ -27,7 +27,7 @@ See the [Prefab Setup](#prefab-setup) section below for step-by-step instruction
using Jovian.PopupSystem;
using Jovian.PopupSystem.UI;
// Create the system. viewPrefab is a reference to your PopupView prefab.
// Create the system. viewPrefab is a reference to your PopupReference prefab.
var popup = new PopupSystem(settings, viewPrefab);
// Register categories you intend to use.
@@ -125,7 +125,7 @@ popup.Show(PopupCategory.Skill, builder => {
}, targetRect);
```
All elements are drawn from a grow-only pool inside `PopupView`. No allocations occur once the pool is warmed.
All elements are drawn from a grow-only pool inside `PopupReference`. No allocations occur once the pool is warmed.
## PopupTrigger
@@ -240,7 +240,7 @@ popupSystem.Tick(Time.deltaTime);
popupSystem.Dispose(); // destroys all popup view GameObjects
```
Each category lazily creates its own `PopupView` instance on first `Show` call. On `Dispose`, all views are destroyed. This ensures no leaked GameObjects when transitioning between game states.
Each category lazily creates its own `PopupReference` instance on first `Show` call. On `Dispose`, all views are destroyed. This ensures no leaked GameObjects when transitioning between game states.
## IPopupAnimator
@@ -318,14 +318,14 @@ var popup = new PopupSystem(settings, viewPrefab, () => new ScalePopupAnimator()
## Prefab Setup
Build the `PopupView` prefab with the following hierarchy:
Build the `PopupReference` prefab with the following hierarchy:
### Step 1: Root GameObject
1. Create a new GameObject named `PopupView`.
1. Create a new GameObject named `PopupReference`.
2. Add a `Canvas` component. Set **Render Mode** to **Screen Space - Overlay**. Set **Sort Order** to match `PopupSettings.sortingOrder` (default 100).
3. Add a `CanvasGroup` component.
4. Add a `PopupView` component (from `Jovian.PopupSystem.UI`).
4. Add a `PopupReference` component (from `Jovian.PopupSystem.UI`).
### Step 2: Background
@@ -354,7 +354,7 @@ Create these as child prefabs (or separate prefabs). Each must be a prefab refer
### Step 5: Wire references
On the `PopupView` component, assign:
On the `PopupReference` component, assign:
- **Content** - the Content RectTransform
- **Canvas Group** - the root CanvasGroup
@@ -386,7 +386,7 @@ The popup system is designed for minimal runtime allocation:
| Type | Namespace | Description |
|---|---|---|
| `IPopupSystem` | `Jovian.PopupSystem` | Main interface for showing/hiding popups. |
| `PopupSystem` | `Jovian.PopupSystem` | Concrete implementation. Constructor: `(PopupSettings, PopupView, Func<IPopupAnimator>)`. |
| `PopupSystem` | `Jovian.PopupSystem` | Concrete implementation. Constructor: `(PopupSettings, PopupReference, Func<IPopupAnimator>)`. |
| `PopupSettings` | `Jovian.PopupSystem` | ScriptableObject with all configuration fields. |
| `PopupCategory` | `Jovian.PopupSystem` | Readonly struct identifying a popup channel. |
| `PopupContentBuilder` | `Jovian.PopupSystem` | Fluent struct for building popup content in callbacks. |
@@ -395,7 +395,7 @@ The popup system is designed for minimal runtime allocation:
| Type | Namespace | Description |
|---|---|---|
| `PopupView` | `Jovian.PopupSystem.UI` | MonoBehaviour managing popup layout, pooling, and positioning. |
| `PopupReference` | `Jovian.PopupSystem.UI` | MonoBehaviour managing popup layout, pooling, and positioning. |
| `PopupTrigger` | `Jovian.PopupSystem.UI` | MonoBehaviour for hover-based popup triggers on UI elements. |
### Animation Types

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d33518dac7899604c9ceeda21897315d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 05f691cbfb7413f4fb735b2ec732ff06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 254bb620ce056dd41905258eb0f070d7

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b146d885db3dcef4fa70abd3f43683d3

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 65d563f87bb09de48b8edd12101cdd11

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 31bcaef770c58d94db7f78106f15fd4e
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bcd1fb0ef93fed0489a43977bc71594b

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 683182ef8e2aa6b4daffc547c481b768

View File

@@ -3,9 +3,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;
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b9f4094c471d0464e95e330331acc813

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 01e69680e496eca4daebbc1874e3a7d9

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e38e313f3665d464b82b22699b2a4634

View File

@@ -7,11 +7,11 @@ using Object = UnityEngine.Object;
namespace Jovian.PopupSystem {
public sealed class PopupSystem : IPopupSystem {
readonly PopupSettings settings;
readonly PopupView viewPrefab;
readonly PopupReference viewPrefab;
readonly Func<IPopupAnimator> animatorFactory;
readonly Dictionary<PopupCategory, ViewState> categories = new();
public PopupSystem(PopupSettings settings, PopupView viewPrefab, Func<IPopupAnimator> animatorFactory = null) {
public PopupSystem(PopupSettings settings, PopupReference viewPrefab, Func<IPopupAnimator> animatorFactory = null) {
this.settings = settings;
this.viewPrefab = viewPrefab;
this.animatorFactory = animatorFactory ?? (() => new FadePopupAnimator());
@@ -171,7 +171,7 @@ namespace Jovian.PopupSystem {
}
private sealed class ViewState {
public PopupView view;
public PopupReference view;
public IPopupAnimator animator;
public int priority;
public float delay;

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 056ed88d12add674798ad4e6300bf222

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4459a298af1a37f47af7b7b70655ee0d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,7 +5,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;

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bc25da4712d7cc4419eb6f364e032431

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4ef9d21a19cd4db4f9d5491202547c05

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3120e52713c91c44d9790e65c94b0869
PackageManifestImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -42,6 +42,16 @@
"com.unity.nuget.newtonsoft-json": "3.2.1"
}
},
"com.jovian.popup-system": {
"version": "file:com.jovian.popup-system",
"depth": 0,
"source": "embedded",
"dependencies": {
"com.unity.textmeshpro": "3.0.6",
"com.unity.inputsystem": "1.18.0",
"com.unity.nuget.newtonsoft-json": "3.2.1"
}
},
"com.jovian.savesystem": {
"version": "file:com.jovian.savesystem",
"depth": 0,