added a disfunctionalk popup system

This commit is contained in:
Sebastian Bularca
2026-04-06 12:28:01 +02:00
parent cbf9f384d9
commit b8fa26865d
28 changed files with 3865 additions and 3663 deletions

View File

@@ -13,7 +13,6 @@ MonoBehaviour:
m_Name: AddressableAssetGroupSortSettings
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.AddressableAssetGroupSortSettings
sortOrder:
- 05b724f967e7d40e69a2f8086a7d78cd
- d7f58d36cc4da874fa45d38c0070c2c2
- e6a1448ac7179f9469ae917578605c81
- a8838bd8f2db41d4c894d2cf8403f207

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 468a46d0ae32c3544b7d98094e6448a9, type: 3}
m_Name: AddressableAssetSettings
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.AddressableAssetSettings
m_DefaultGroup: 05b724f967e7d40e69a2f8086a7d78cd
m_DefaultGroup: d7f58d36cc4da874fa45d38c0070c2c2
m_currentHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
@@ -60,7 +60,6 @@ MonoBehaviour:
m_BuildAddressablesWithPlayerBuild: 0
m_overridePlayerVersion: '[UnityEditor.PlayerSettings.bundleVersion]'
m_GroupAssets:
- {fileID: 11400000, guid: 6c79f6f00c1f84b1c854543c84d05d0f, type: 2}
- {fileID: 11400000, guid: 8aabd2323ded16346970904048573037, type: 2}
- {fileID: 11400000, guid: 643aef87ff0fa05488c1a0982ec49f26, type: 2}
- {fileID: 11400000, guid: 2ddfa0c67160cbe4f9669d176f0ee01b, type: 2}

View File

@@ -40,11 +40,21 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 15529a69a8231ac43b1108efbaad83b6
m_Address: Assets/Prefabs/UI/CharacterCreationReference.prefab
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 21833c6afc1e0b047a3c49dc9ea35996
m_Address: Assets/Art/UI/portait_hero_05.png
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 2dfcc209b5aff734d863147e5614563c
m_Address: PopupReferencePrefab
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 3225768f79644af4dbda96b8f9d57ed2
m_Address: Assets/Art/UI/menu_supply_bar_full.png
m_ReadOnly: 0
@@ -75,6 +85,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 571f2dd77fb442d499cdc9c2afe9f98d
m_Address: PopupSettings
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 60a7c1e10ed7ff94cbe191d9d3e305ed
m_Address: Assets/Art/UI/menu_corner.png
m_ReadOnly: 0
@@ -206,6 +221,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: ed9b80145a89c8a4f8d456971d242c3c
m_Address: PortraitsHolder
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: f37df040ec9864f4dbafe3f5e6dfe4d9
m_Address: DefaultPartySettings
m_ReadOnly: 0

View File

@@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
m_Name: Default Local Group
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.AddressableAssetGroup
m_GroupName: Default Local Group
m_GUID: 05b724f967e7d40e69a2f8086a7d78cd
m_SerializeEntries:
- m_GUID: 15529a69a8231ac43b1108efbaad83b6
m_Address: Assets/Prefabs/UI/CharacterCreationReference.prefab
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: ed9b80145a89c8a4f8d456971d242c3c
m_Address: PortraitsHolder
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: 7e98b357dd76a43e191428299c44eef2, type: 2}
m_SchemaSet:
m_Schemas:
- {fileID: 11400000, guid: 5b53a1ca29cdf45fdb72fa3e94514b82, type: 2}
- {fileID: 11400000, guid: 9148d31c5a1d74102a17c9d6be0baf0e, type: 2}

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6c79f6f00c1f84b1c854543c84d05d0f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,48 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3}
m_Name: Default Local Group_BundledAssetGroupSchema
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.BundledAssetGroupSchema
m_Group: {fileID: 11400000, guid: 6c79f6f00c1f84b1c854543c84d05d0f, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
m_InternalIdNamingMode: 0
m_CacheClearBehavior: 0
m_IncludeInBuild: 1
m_BundledAssetProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider
m_StripDownloadOptions: 0
m_ForceUniqueProvider: 0
m_UseAssetBundleCache: 1
m_UseAssetBundleCrc: 1
m_UseAssetBundleCrcForCachedBundles: 1
m_UseUWRForLocalBundles: 0
m_Timeout: 0
m_ChunkedTransfer: 0
m_RedirectLimit: -1
m_RetryCount: 0
m_BuildPath:
m_Id: 8fbce5c7cea8b47209ad27b2e4685031
m_LoadPath:
m_Id: 8e5cf788c2f044c5ba2465efea14a827
m_BundleMode: 0
m_AssetBundleProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
m_UseDefaultSchemaSettings: 0
m_SelectedPathPairIndex: 0
m_BundleNaming: 0
m_AssetLoadMode: 0

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 5b53a1ca29cdf45fdb72fa3e94514b82
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,16 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
m_Name: Default Local Group_ContentUpdateGroupSchema
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.ContentUpdateGroupSchema
m_Group: {fileID: 11400000, guid: 6c79f6f00c1f84b1c854543c84d05d0f, type: 2}
m_StaticContent: 0

View File

@@ -1,3 +1,5 @@
using Jovian.PopupSystem;
using Jovian.PopupSystem.UI;
using Jovian.SaveSystem;
using Jovian.ZoneSystem;
using Nox.Core;
@@ -39,6 +41,7 @@ namespace Nox.Game {
private TimeHandler timeHandler;
private PartyInventoryHandler partyInventoryHandler;
private PartyGuiView partyGuiView;
private IPopupSystem popupSystem;
public AdventurePlayMode(
PlatformSettings platformSettings,
@@ -134,7 +137,16 @@ namespace Nox.Game {
if(partyGuiView == null && guiReferences.partyMemberSlotPrefab != null) {
var portraitsHolder = Addressables.LoadAssetAsync<PortraitsHolder>("PortraitsHolder").WaitForCompletion();
partyGuiView = new PartyGuiView(guiReferences.portraitsContainer, guiReferences.partyMemberSlotPrefab, portraitsHolder);
if(popupSystem == null) {
var popupSettings = Addressables.LoadAssetAsync<PopupSettings>("PopupSettings").WaitForCompletion();
var popupViewPrefab = Addressables.LoadAssetAsync<GameObject>("PopupReferencePrefab").WaitForCompletion().GetComponent<PopupReference>();
var guiCanvas = guiReferences.GetComponentInParent<Canvas>().transform;
popupSystem = new PopupSystem(popupSettings, popupViewPrefab, guiCanvas);
popupSystem.RegisterCategory(PopupCategory.Character, priority: 10);
}
partyGuiView = new PartyGuiView(guiReferences.portraitsContainer, guiReferences.partyMemberSlotPrefab, portraitsHolder, popupSystem);
partyGuiView.Initialize(partyDefinition);
}
@@ -151,6 +163,7 @@ namespace Nox.Game {
partyMovementHandler.Tick();
adventureView.Tick();
partyGuiView?.Tick();
popupSystem?.Tick(Time.deltaTime);
if(inputActions.UI.PauseMenu.WasPerformedThisFrame()) {
gameDataState.ChangePlayMode(PlayMode.PauseMenu);
@@ -178,6 +191,7 @@ namespace Nox.Game {
cameraController?.Dispose();
partyMovementHandler?.Dispose();
partyGuiView?.Dispose();
popupSystem?.Dispose();
}
}

View File

@@ -1,4 +1,8 @@
using Jovian.Logger;
using System;
using System.Collections.Generic;
using Jovian.PopupSystem;
using Jovian.PopupSystem.UI;
using Nox.UI;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -8,15 +12,17 @@ namespace Nox.Game.UI {
private readonly Transform portraitsContainer;
private readonly PartyMemberSlot slotPrefab;
private readonly PortraitsHolder portraitsHolder;
private readonly IPopupSystem popupSystem;
private readonly List<PartyMemberSlot> activeSlots = new();
private PartyDefinition trackedParty;
private int trackedMemberCount;
public PartyGuiView(Transform portraitsContainer, PartyMemberSlot slotPrefab, PortraitsHolder portraitsHolder) {
public PartyGuiView(Transform portraitsContainer, PartyMemberSlot slotPrefab, PortraitsHolder portraitsHolder, IPopupSystem popupSystem = null) {
this.portraitsContainer = portraitsContainer;
this.slotPrefab = slotPrefab;
this.portraitsHolder = portraitsHolder;
this.popupSystem = popupSystem;
}
public void Initialize(PartyDefinition party) {
@@ -74,6 +80,72 @@ namespace Nox.Game.UI {
UpdateSlotStats(slot, member);
activeSlots.Add(slot);
}
// Initialize all popup triggers under the container
if(popupSystem != null) {
popupSystem.InitializeTriggersInChildren(portraitsContainer, trigger => {
var slot = trigger.GetComponentInParent<PartyMemberSlot>();
if(slot == null) {
return;
}
var slotIndex = activeSlots.IndexOf(slot);
if(slotIndex < 0 || slotIndex >= trackedParty.members.Count) {
return;
}
var member = trackedParty.members[slotIndex];
trigger.Initialize(popupSystem, builder => BuildCharacterPopup(builder, member));
});
}
}
private void BuildCharacterPopup(PopupContentBuilder builder, CharacterDefinition member) {
GlobalLogger.LogInfo($"Building character popup for {member.Name}", LogCategory.UI);
// Header
builder.AddHeader(member.Name);
builder.AddText($"{member.Race} {member.Class}", "#CCCCCC");
builder.AddText($"Role: {member.Role}");
builder.AddSeparator();
// Stats
if(member.Stats?.stats != null) {
foreach(var stat in member.Stats.stats) {
if(stat.stat == StatType.None) {
continue;
}
builder.AddStat(stat.stat.ToString(), stat.value);
}
}
builder.AddSeparator();
// Attributes
if(member.Attributes?.attributes != null) {
foreach(var attr in member.Attributes.attributes) {
if(attr.attribute == AttributeType.None) {
continue;
}
builder.AddStat(attr.attribute.ToString(), attr.value);
}
}
builder.AddSeparator();
// Perks
if(member.Perks?.perks != null && member.Perks.perks.Count > 0) {
builder.AddText("Perks", "#FFD700");
foreach(var perk in member.Perks.perks) {
builder.AddText($" {perk.Name}");
}
builder.AddSeparator();
}
// Modifiers
if(member.Modifiers?.modifiers is { Count: > 0 }) {
builder.AddText("Modifiers", "#87CEEB");
foreach(var mod in member.Modifiers.modifiers) {
var target = mod.Target != null ? mod.Target.ToString() : "";
builder.AddText($" {mod.Name} ({mod.Operation} {mod.Value} {target})");
}
}
}
private static void UpdateSlotStats(PartyMemberSlot slot, CharacterDefinition member) {

View File

@@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e38e313f3665d464b82b22699b2a4634, type: 3}
m_Name: PopupSettings
m_EditorClassIdentifier: Jovian.PopupSystem::Jovian.PopupSystem.PopupSettings
popupDelay: 0.4
fadeDuration: 0.2
defaultAnchorSide: 3
screenEdgePadding: 10
maxPopupWidth: 400
sortingOrder: 100
followMouseOffset: {x: 15, y: -15}
touchHoldDuration: 0.6
gamepadFocusTrigger: 1
categoryPriorities:
- category:
id: Character
priority: 0
categoryDelayOverrides: []

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9148d31c5a1d74102a17c9d6be0baf0e
guid: 571f2dd77fb442d499cdc9c2afe9f98d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

View File

@@ -59,7 +59,7 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@@ -409,7 +409,7 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 0.6156863, g: 0.6509804, b: 0.63529414, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@@ -573,6 +573,7 @@ GameObject:
- component: {fileID: 635472993512454406}
- component: {fileID: 713960887884573537}
- component: {fileID: 1445432521138085750}
- component: {fileID: 250019032835520348}
m_Layer: 5
m_Name: HeroPortrait
m_TagString: Untagged
@@ -639,6 +640,22 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &250019032835520348
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5596812297104419965}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ef9d21a19cd4db4f9d5491202547c05, type: 3}
m_Name:
m_EditorClassIdentifier: Jovian.PopupSystem::Jovian.PopupSystem.UI.PopupTrigger
category:
id: Character
anchorSide: 3
positionMode: 0
--- !u!1 &7521504480723579343
GameObject:
m_ObjectHideFlags: 0
@@ -786,7 +803,7 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 0.48627454, g: 0.06666667, b: 0.08627451, a: 1}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:

View File

@@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 1241885294582312999}
- component: {fileID: 1942692710355281447}
- component: {fileID: 6612787789151041457}
- component: {fileID: 743893275569378137}
- component: {fileID: 6777404126897807012}
m_Layer: 5
m_Name: PopupHeader
m_TagString: Untagged
@@ -32,11 +34,11 @@ RectTransform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -50, y: 319}
m_SizeDelta: {x: 468.9631, y: 65.1437}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 741.369, y: -210.32233}
m_SizeDelta: {x: 214.8432, y: 16}
m_Pivot: {x: 0, y: 1}
--- !u!222 &1942692710355281447
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -92,12 +94,12 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 50
m_fontSize: 16
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 50
m_fontSizeMin: 5
m_fontSizeMax: 16
m_fontStyle: 17
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
@@ -137,3 +139,37 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &743893275569378137
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7034836061828108288}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: 1
m_FlexibleHeight: 1
m_LayoutPriority: 1
--- !u!114 &6777404126897807012
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7034836061828108288}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 0
m_VerticalFit: 0

View File

@@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 3721371113883694790}
- component: {fileID: 5474191059961008429}
- component: {fileID: 7093821785826926595}
- component: {fileID: 4096566878556632262}
- component: {fileID: 6531872381202374245}
m_Layer: 5
m_Name: PopupIcon
m_TagString: Untagged
@@ -32,10 +34,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 989.9083, y: -555.6331}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5474191059961008429
CanvasRenderer:
@@ -75,3 +77,37 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &4096566878556632262
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5887814251614319338}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 2
m_VerticalFit: 2
--- !u!114 &6531872381202374245
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5887814251614319338}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1

View File

@@ -9,11 +9,13 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 623181081371217224}
- component: {fileID: 5526672357430983468}
- component: {fileID: 1835601435911948781}
- component: {fileID: 695849844002832445}
- component: {fileID: 3081303906751693297}
- component: {fileID: -4214546602618600400}
- component: {fileID: 7236468329886607693}
m_Layer: 5
m_Name: PopupReference
m_Name: PopupReferencePrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -32,37 +34,13 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8899521584296352500}
- {fileID: 176628901263125209}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &5526672357430983468
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1599460330468667833}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 2
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 1
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 100
m_TargetDisplay: 0
m_SizeDelta: {x: -1679, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!225 &1835601435911948781
CanvasGroup:
m_ObjectHideFlags: 0
@@ -95,6 +73,66 @@ MonoBehaviour:
statPrefab: {fileID: 1843470073663794312, guid: 5882db210c62d8647858933649f64c29, type: 3}
imagePrefab: {fileID: 7093821785826926595, guid: 5e715f4b614d02b4fa0b4d3fcfe3c053, type: 3}
separatorPrefab: {fileID: 5214286777979083404, guid: d5230f8d67d5a8844a7230f03937ed17, type: 3}
--- !u!223 &3081303906751693297
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1599460330468667833}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 100
m_TargetDisplay: 0
--- !u!114 &-4214546602618600400
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1599460330468667833}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.CanvasScaler
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 1920, y: 1080}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0.5
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!114 &7236468329886607693
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1599460330468667833}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &3774543863822571266
GameObject:
m_ObjectHideFlags: 0
@@ -105,7 +143,6 @@ GameObject:
m_Component:
- component: {fileID: 176628901263125209}
- component: {fileID: 2618782962856630769}
- component: {fileID: 6988667242421749217}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
@@ -120,18 +157,18 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3774543863822571266}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 623181081371217224}
m_Father: {fileID: 8899521584296352500}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -52.972595, y: -49.99994}
m_SizeDelta: {x: 1078.9565, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -254.5}
m_SizeDelta: {x: 0, y: -10}
m_Pivot: {x: 0, y: 1}
--- !u!114 &2618782962856630769
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -151,27 +188,13 @@ MonoBehaviour:
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: 2
m_ChildForceExpandWidth: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 0
m_ChildControlWidth: 1
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!114 &6988667242421749217
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3774543863822571266}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &7921791084240859601
GameObject:
m_ObjectHideFlags: 0
@@ -183,7 +206,7 @@ GameObject:
- component: {fileID: 8899521584296352500}
- component: {fileID: 4414385109869753182}
- component: {fileID: 532483268298381524}
- component: {fileID: 361417494609917237}
- component: {fileID: 5892365158095607894}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
@@ -202,14 +225,15 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 176628901263125209}
m_Father: {fileID: 623181081371217224}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1291.7905, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
m_SizeDelta: {x: 200, y: 10}
m_Pivot: {x: 0, y: 1}
--- !u!222 &4414385109869753182
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -238,8 +262,8 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 52125a3c3df558448a5af5a04dbf8d2d, type: 3}
m_Type: 0
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
@@ -248,14 +272,14 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &361417494609917237
--- !u!114 &5892365158095607894
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7921791084240859601}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:

View File

@@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 1299250784458062776}
- component: {fileID: 397894273528688440}
- component: {fileID: 5214286777979083404}
- component: {fileID: 5468380481122466219}
- component: {fileID: 6693505102576290950}
m_Layer: 5
m_Name: PopupSeparator
m_TagString: Untagged
@@ -32,11 +34,11 @@ RectTransform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 13.6381, y: -113.30817}
m_SizeDelta: {x: 657.849, y: 4.6163}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 901.33813, y: -667.00006}
m_SizeDelta: {x: -1775.4, y: -1107.3838}
m_Pivot: {x: 0, y: 1}
--- !u!222 &397894273528688440
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -75,3 +77,37 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &5468380481122466219
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3426404626348166472}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!114 &6693505102576290950
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3426404626348166472}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 0
m_VerticalFit: 0

View File

@@ -35,7 +35,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 272.3595, y: 65.1437}
m_SizeDelta: {x: 184.47, y: 25.6566}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4060824052845831606
CanvasRenderer:
@@ -92,14 +92,14 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 33.2
m_fontSize: 14
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 33.2
m_fontSizeMin: 5
m_fontSizeMax: 14
m_fontStyle: 17
m_HorizontalAlignment: 2
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
@@ -147,6 +147,8 @@ GameObject:
m_Component:
- component: {fileID: 1843470073663794312}
- component: {fileID: 7829576473989485776}
- component: {fileID: 5426390226938478828}
- component: {fileID: 2356989198378852018}
m_Layer: 0
m_Name: PopupStat
m_TagString: Untagged
@@ -170,11 +172,11 @@ RectTransform:
- {fileID: 8849778187297648043}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -50, y: 120}
m_SizeDelta: {x: 482.4235, y: 67.3541}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 835.73267, y: -543.18}
m_SizeDelta: {x: 308.5346, y: 25.640076}
m_Pivot: {x: 0, y: 1}
--- !u!114 &7829576473989485776
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -201,6 +203,40 @@ MonoBehaviour:
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!114 &5426390226938478828
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6246834368258800846}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 0
m_VerticalFit: 0
--- !u!114 &2356989198378852018
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6246834368258800846}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: 1
m_FlexibleHeight: 1
m_LayoutPriority: 1
--- !u!1 &9078345592336978365
GameObject:
m_ObjectHideFlags: 0
@@ -236,7 +272,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 196.91, y: 65.1437}
m_SizeDelta: {x: 119.4161, y: 25.657}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7828883841352225497
CanvasRenderer:
@@ -293,14 +329,14 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 31.4
m_fontSize: 12
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 1.5
m_fontSizeMax: 31.4
m_fontSizeMax: 12
m_fontStyle: 0
m_HorizontalAlignment: 2
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0

View File

@@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 3436634297340404643}
- component: {fileID: 386873398398603487}
- component: {fileID: 2506259255305457008}
- component: {fileID: 8135718718032805930}
- component: {fileID: 8858913019524689709}
m_Layer: 5
m_Name: PopupText
m_TagString: Untagged
@@ -32,11 +34,11 @@ RectTransform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -50, y: 222}
m_SizeDelta: {x: 468.9631, y: 65.1437}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 705.51843, y: -303.7433}
m_SizeDelta: {x: 133.05402, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!222 &386873398398603487
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -92,12 +94,12 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 34.2
m_fontSize: 12
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 1.5
m_fontSizeMax: 34.2
m_fontSizeMax: 12
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
@@ -137,3 +139,37 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &8135718718032805930
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3157287847714375358}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.ContentSizeFitter
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!114 &8858913019524689709
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3157287847714375358}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: 1
m_FlexibleHeight: 1
m_LayoutPriority: 1

View File

@@ -596,6 +596,10 @@ PrefabInstance:
propertyPath: m_Name
value: GUI
objectReference: {fileID: 0}
- target: {fileID: 3496454433051527820, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5178544305442097730, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_Pivot.x
value: 0

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Jovian.PopupSystem.Editor {
[CustomPropertyDrawer(typeof(PopupCategory))]
public sealed class PopupCategoryDrawer : PropertyDrawer {
private static readonly string[] builtInIds = {
"Character",
"Item",
"Skill",
"General"
};
private const string customLabel = "Custom...";
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
var idProp = FindIdProperty(property);
if(idProp == null) {
return EditorGUIUtility.singleLineHeight;
}
var currentValue = idProp.stringValue ?? "";
var isCustom = Array.IndexOf(builtInIds, currentValue) < 0;
// Two lines when in custom mode: dropdown + text field
return isCustom
? EditorGUIUtility.singleLineHeight * 2 + 2
: EditorGUIUtility.singleLineHeight;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
EditorGUI.BeginProperty(position, label, property);
var idProp = FindIdProperty(property);
if(idProp == null) {
EditorGUI.LabelField(position, label.text, "Cannot resolve PopupCategory id field");
EditorGUI.EndProperty();
return;
}
var currentValue = idProp.stringValue ?? "";
var builtInIndex = Array.IndexOf(builtInIds, currentValue);
var isCustom = builtInIndex < 0 && !string.IsNullOrEmpty(currentValue);
// Build display options: built-in entries + "Custom..."
var options = new List<string>(builtInIds);
options.Add(customLabel);
// Determine selected index
int selectedIndex;
if(builtInIndex >= 0) {
selectedIndex = builtInIndex;
}
else {
selectedIndex = options.Count - 1; // "Custom..."
}
// First line: dropdown
var dropdownRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
var newIndex = EditorGUI.Popup(dropdownRect, label.text, selectedIndex, options.ToArray());
if(newIndex != selectedIndex) {
if(newIndex < builtInIds.Length) {
idProp.stringValue = builtInIds[newIndex];
}
else {
// Switched to custom — seed with a placeholder if currently built-in
if(!isCustom) {
idProp.stringValue = "NewCategory";
}
}
}
// Second line: editable text field when custom
var finalIsCustom = newIndex >= builtInIds.Length || (newIndex == selectedIndex && isCustom);
if(finalIsCustom) {
var textRect = new Rect(
position.x + EditorGUIUtility.labelWidth + 2,
position.y + EditorGUIUtility.singleLineHeight + 2,
position.width - EditorGUIUtility.labelWidth - 2,
EditorGUIUtility.singleLineHeight);
var newValue = EditorGUI.TextField(textRect, idProp.stringValue);
if(newValue != idProp.stringValue) {
idProp.stringValue = newValue;
}
}
EditorGUI.EndProperty();
}
private static SerializedProperty FindIdProperty(SerializedProperty property) {
// readonly struct with [SerializeField] readonly string id
// Unity serializes this as "id" directly
var prop = property.FindPropertyRelative("id");
if(prop != null) {
return prop;
}
// Fallback: auto-property backing field pattern
return property.FindPropertyRelative("<id>k__BackingField");
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9cc96a089d31fe14cbadf6c59ea0c9aa

View File

@@ -1,8 +1,10 @@
using System;
using Jovian.PopupSystem.UI;
using UnityEngine;
namespace Jovian.PopupSystem {
public interface IPopupSystem {
void InitializeTriggersInChildren(Transform parent, Action<PopupTrigger> configureTrigger);
void RegisterCategory(PopupCategory category, int priority = 0);
void Show(PopupCategory category, Action<PopupContentBuilder> buildContent,
RectTransform anchor = null, AnchorSide? anchorSide = null);

View File

@@ -3,8 +3,8 @@ using UnityEngine;
namespace Jovian.PopupSystem {
[Serializable]
public readonly struct PopupCategory : IEquatable<PopupCategory> {
[SerializeField] readonly string id;
public struct PopupCategory : IEquatable<PopupCategory> {
[SerializeField] string id;
public string Id => id;

View File

@@ -9,11 +9,13 @@ namespace Jovian.PopupSystem {
readonly PopupSettings settings;
readonly PopupReference viewPrefab;
readonly Func<IPopupAnimator> animatorFactory;
readonly Transform canvasParent;
readonly Dictionary<PopupCategory, ViewState> categories = new();
public PopupSystem(PopupSettings settings, PopupReference viewPrefab, Func<IPopupAnimator> animatorFactory = null) {
public PopupSystem(PopupSettings settings, PopupReference viewPrefab, Transform canvasParent = null, Func<IPopupAnimator> animatorFactory = null) {
this.settings = settings;
this.viewPrefab = viewPrefab;
this.canvasParent = canvasParent;
this.animatorFactory = animatorFactory ?? (() => new FadePopupAnimator());
}
@@ -110,6 +112,13 @@ namespace Jovian.PopupSystem {
}
}
public void InitializeTriggersInChildren(Transform parent, Action<PopupTrigger> configureTrigger) {
var triggers = parent.GetComponentsInChildren<PopupTrigger>(true);
foreach(var trigger in triggers) {
configureTrigger(trigger);
}
}
public void Dispose() {
foreach(var kvp in categories) {
if(kvp.Value.view != null) {
@@ -148,14 +157,24 @@ namespace Jovian.PopupSystem {
if(state.view != null) {
return;
}
state.view = Object.Instantiate(viewPrefab);
state.view.SetVisible(false);
state.view.SetMaxWidth(settings.maxPopupWidth);
if(canvasParent != null) {
// Parent under existing scene Canvas — nested Canvas inherits CanvasScaler
state.view = Object.Instantiate(viewPrefab, canvasParent);
}
else {
state.view = Object.Instantiate(viewPrefab);
}
// Configure Canvas as override sorting so it renders on top
var canvas = state.view.GetComponent<Canvas>();
if(canvas != null) {
canvas.overrideSorting = true;
canvas.sortingOrder = settings.sortingOrder;
}
state.view.SetVisible(false);
state.view.SetMaxWidth(settings.maxPopupWidth);
}
private void DismissLowerPriority(int showingPriority) {

View File

@@ -45,6 +45,8 @@ namespace Jovian.PopupSystem.UI {
float maxWidth;
bool isVisible;
bool layoutDirty;
Canvas rootCanvas;
Camera canvasCamera;
public CanvasGroup CanvasGroup => canvasGroup;
public RectTransform Content => content;
@@ -172,9 +174,20 @@ namespace Jovian.PopupSystem.UI {
}
}
private void CacheCanvas() {
if(rootCanvas != null) {
return;
}
rootCanvas = GetComponentInParent<Canvas>()?.rootCanvas;
canvasCamera = rootCanvas != null && rootCanvas.renderMode != RenderMode.ScreenSpaceOverlay
? rootCanvas.worldCamera : null;
}
private void PositionAnchoredTo(RectTransform target, AnchorSide side) {
var targetRect = GetScreenRect(target);
var popupSize = GetScreenRect((RectTransform)transform).size;
CacheCanvas();
var targetRect = GetScreenRect(target, canvasCamera);
var popupRect = GetScreenRect((RectTransform)transform, canvasCamera);
var popupSize = popupRect.size;
var pos = side switch {
AnchorSide.Below => new Vector2(targetRect.center.x - popupSize.x * 0.5f, targetRect.yMin - popupSize.y),
@@ -188,26 +201,36 @@ namespace Jovian.PopupSystem.UI {
}
private void PositionAtScreenPoint(Vector2 screenPos) {
CacheCanvas();
var rt = (RectTransform)transform;
if(layoutDirty) {
LayoutRebuilder.ForceRebuildLayoutImmediate(content);
layoutDirty = false;
}
var popupSize = rt.rect.size;
var popupSize = GetScreenRect(rt, canvasCamera).size;
// Clamp to screen
screenPos.x = Mathf.Clamp(screenPos.x, screenEdgePadding, Screen.width - popupSize.x - screenEdgePadding);
screenPos.y = Mathf.Clamp(screenPos.y, screenEdgePadding, Screen.height - popupSize.y - screenEdgePadding);
rt.position = screenPos;
// Convert screen position to parent local space
var parentRt = rt.parent as RectTransform;
if(parentRt != null) {
RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRt, screenPos, canvasCamera, out var localPos);
rt.localPosition = localPos;
}
else {
rt.position = screenPos;
}
}
private static readonly Vector3[] cornersBuffer = new Vector3[4];
private static Rect GetScreenRect(RectTransform rt) {
private static Rect GetScreenRect(RectTransform rt, Camera camera) {
rt.GetWorldCorners(cornersBuffer);
var min = new Vector2(cornersBuffer[0].x, cornersBuffer[0].y);
var max = new Vector2(cornersBuffer[2].x, cornersBuffer[2].y);
// Convert world corners to screen space
var min = RectTransformUtility.WorldToScreenPoint(camera, cornersBuffer[0]);
var max = RectTransformUtility.WorldToScreenPoint(camera, cornersBuffer[2]);
return new Rect(min, max - min);
}
}