Add support for popover labels

This commit is contained in:
Jet the Hawk 2023-03-03 16:46:59 -05:00
parent a2eb0514ee
commit aec2e22da5
14 changed files with 827 additions and 104 deletions

File diff suppressed because one or more lines are too long

View file

@ -34,7 +34,6 @@ Transform:
- {fileID: 8631239039538912615}
- {fileID: 8239129150798170454}
- {fileID: 928485812074972480}
- {fileID: 5099507500598303435}
- {fileID: 2138699188567816693}
- {fileID: 3676830287291953270}
m_Father: {fileID: 0}
@ -88,7 +87,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 1449612830529223301, guid: ade9a53a41b91964a8c35b2c35a439bf, type: 3}
propertyPath: m_RootOrder
value: 4
value: 3
objectReference: {fileID: 0}
- target: {fileID: 1449612830529223301, guid: ade9a53a41b91964a8c35b2c35a439bf, type: 3}
propertyPath: m_LocalPosition.x
@ -327,68 +326,6 @@ Transform:
m_CorrespondingSourceObject: {fileID: 4943637528432496041, guid: 755f7ece1d427a443a828206ac57f8f0, type: 3}
m_PrefabInstance: {fileID: 3698306379014017230}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6207429681634773126
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1191197961681005175}
m_Modifications:
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1777580187112757083, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
propertyPath: m_Name
value: Steamworks
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
--- !u!4 &5099507500598303435 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1216024012788109901, guid: 69af82d1d370d004cac6b6402915535d, type: 3}
m_PrefabInstance: {fileID: 6207429681634773126}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &8934673873687550751
PrefabInstance:
m_ObjectHideFlags: 0
@ -398,7 +335,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 5258215514604514153, guid: b54b6b94e467cc54297711bc903849b4, type: 3}
propertyPath: m_RootOrder
value: 5
value: 4
objectReference: {fileID: 0}
- target: {fileID: 5258215514604514153, guid: b54b6b94e467cc54297711bc903849b4, type: 3}
propertyPath: m_LocalPosition.x

View file

@ -53,5 +53,6 @@ MonoBehaviour:
backdropPrefab: {fileID: 1876961014414637132, guid: 437971ffa9ad15844ab503f02119cf2b, type: 3}
desktopPrefab: {fileID: 94841126449236779, guid: 2d3bebba157bed94fa6fe837f5cbd2b8, type: 3}
windowManagerPrefab: {fileID: 3873711479734453863, guid: 180479df6586f3f41aa4d32d884cd9e5, type: 3}
popoverLayerPrefab: {fileID: 6738298882049385100, guid: 1976ad0fb0713fe438182c366418dcc7, type: 3}
environmentVariables: {fileID: 11400000, guid: 66aac6d84e661da45acad8d220849082, type: 2}
defaultBackdrop: {fileID: 0}

View file

@ -2,6 +2,7 @@
using OS.Devices;
using UI.Backdrop;
using UI.Login;
using UI.Popovers;
using UI.Shell;
using UI.Windowing;
using UnityEngine;
@ -18,5 +19,6 @@ namespace Player
public Desktop Desktop;
public WindowManager WindowManager;
public LoginManager LoginManager;
public PopoverLayer PopoverLayer;
}
}

View file

@ -44,6 +44,9 @@ namespace Player
[SerializeField]
private GameObject windowManagerPrefab = null!;
[SerializeField]
private GameObject popoverLayerPrefab = null!;
[Header("Environment")]
[SerializeField]
private EnvironmentVariablesAsset environmentVariables = null!;
@ -83,6 +86,7 @@ namespace Player
GameObject desktopGameObject = Instantiate(desktopPrefab, uiRootGameObject.transform);
GameObject loginManagerGameObject = Instantiate(loginManagerPrefab, uiRootGameObject.transform);
GameObject windowManagerGameObject = Instantiate(windowManagerPrefab, uiRootGameObject.transform);
GameObject popoverLayerGameObject = Instantiate(popoverLayerPrefab, uiRootGameObject.transform);
desktopPrefab.SetActive(true);
@ -92,6 +96,7 @@ namespace Player
desktopGameObject.MustGetComponent(out player.Desktop);
windowManagerGameObject.MustGetComponent(out player.WindowManager);
loginManagerGameObject.MustGetComponent(out player.LoginManager);
popoverLayerGameObject.MustGetComponent(out player.PopoverLayer);
// set the default backdrop
player.BackdropController.SetBackdrop(new BackdropSettings(Color.white, defaultBackdrop));

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ef67c9f2b4d24a6ab8e7c792c7e0f134
timeCreated: 1677876020

View file

@ -0,0 +1,432 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1504231438253210307
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3594520209665177991}
- component: {fileID: 7416353521465201253}
- component: {fileID: 20768304918503503}
- component: {fileID: 4050182641232143052}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3594520209665177991
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1504231438253210307}
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:
- {fileID: 431296676719001540}
m_Father: {fileID: 6234230040571382011}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7416353521465201253
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1504231438253210307}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 10
m_Right: 10
m_Top: 10
m_Bottom: 10
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 1
m_ChildControlHeight: 1
m_ChildScaleWidth: 1
m_ChildScaleHeight: 1
m_ReverseArrangement: 0
--- !u!222 &20768304918503503
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1504231438253210307}
m_CullTransparentMesh: 1
--- !u!114 &4050182641232143052
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1504231438253210307}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &3563053888242493476
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 431296676719001540}
- component: {fileID: 2169481515045117187}
- component: {fileID: 967393148622265929}
m_Layer: 5
m_Name: Label
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &431296676719001540
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3563053888242493476}
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: 3594520209665177991}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2169481515045117187
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3563053888242493476}
m_CullTransparentMesh: 1
--- !u!114 &967393148622265929
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3563053888242493476}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Popover Label
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: f509d26bf7ce06243bf3324babe5918e, type: 2}
m_sharedMaterial: {fileID: -6538113406969041546, guid: f509d26bf7ce06243bf3324babe5918e, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 12
m_fontSizeBase: 12
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 6
m_fontSizeMax: 24
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 1
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &6738298882049385100
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5186210954818110314}
- component: {fileID: 8242882438896932943}
- component: {fileID: 6646770870724762443}
- component: {fileID: 4937996041671874689}
m_Layer: 5
m_Name: Popover Layer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5186210954818110314
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6738298882049385100}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6234230040571382011}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!223 &8242882438896932943
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6738298882049385100}
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_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &6646770870724762443
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6738298882049385100}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 1920, y: 1080}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 1
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!114 &4937996041671874689
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6738298882049385100}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d85257644eec47e3a658ac7021749907, type: 3}
m_Name:
m_EditorClassIdentifier:
popoverTransform: {fileID: 6234230040571382011}
popoverCanvasGroup: {fileID: 4882710268341334349}
popoverLabel: {fileID: 967393148622265929}
--- !u!1 &8483764300007929611
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6234230040571382011}
- component: {fileID: 8306763629829147284}
- component: {fileID: 3294461407644302103}
- component: {fileID: 4882710268341334349}
m_Layer: 5
m_Name: Popover
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6234230040571382011
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8483764300007929611}
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:
- {fileID: 3594520209665177991}
m_Father: {fileID: 5186210954818110314}
m_RootOrder: 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: 600, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8306763629829147284
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8483764300007929611}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!114 &3294461407644302103
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8483764300007929611}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 10
m_Right: 10
m_Top: 10
m_Bottom: 10
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 1
m_ChildControlHeight: 1
m_ChildScaleWidth: 1
m_ChildScaleHeight: 1
m_ReverseArrangement: 0
--- !u!225 &4882710268341334349
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8483764300007929611}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1976ad0fb0713fe438182c366418dcc7
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,106 @@
#nullable enable
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using Utility;
namespace UI.Popovers
{
public class Popover :
MonoBehaviour,
IPointerEnterHandler,
IPointerExitHandler,
IPointerMoveHandler
{
private RectTransform myTransform;
private bool isDisplayingPopOver = false;
private float timeUntilDisplay = 0;
private bool isCountingDown = false;
private PopoverLayer? popoverLayer;
[SerializeField]
private string text = string.Empty;
[SerializeField]
private float delaySeconds = 0.1f;
public string Text
{
get => text;
set => text = value;
}
private void Awake()
{
this.MustGetComponent(out myTransform);
}
private void OnDisable()
{
if (isDisplayingPopOver && popoverLayer != null)
popoverLayer.HidePopover();
isCountingDown = false;
isDisplayingPopOver = false;
popoverLayer = null;
}
private void Update()
{
if (popoverLayer == null)
return;
if (isDisplayingPopOver)
return;
if (!isCountingDown)
return;
if (timeUntilDisplay > 0)
{
timeUntilDisplay -= Time.deltaTime;
return;
}
isCountingDown = false;
isDisplayingPopOver = true;
popoverLayer.ShowPopover(myTransform, text);
}
/// <inheritdoc />
public void OnPointerEnter(PointerEventData eventData)
{
PopoverLayer? layer = FindObjectOfType<PopoverLayer>();
if (layer == null)
return;
this.popoverLayer = layer;
this.isCountingDown = true;
this.timeUntilDisplay = delaySeconds;
}
/// <inheritdoc />
public void OnPointerExit(PointerEventData eventData)
{
if (isDisplayingPopOver && popoverLayer != null)
popoverLayer.HidePopover();
isCountingDown = false;
isDisplayingPopOver = false;
popoverLayer = null;
}
/// <inheritdoc />
public void OnPointerMove(PointerEventData eventData)
{
if (isDisplayingPopOver)
return;
if (!isCountingDown)
return;
timeUntilDisplay = delaySeconds;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6a67e7f94fa9438c87aa82d7cee3504d
timeCreated: 1677876899

View file

@ -0,0 +1,68 @@
#nullable enable
using System;
using TMPro;
using UnityEngine;
using Utility;
namespace UI.Popovers
{
public class PopoverLayer : MonoBehaviour
{
private RectTransform myRect;
[Header("UI")]
[SerializeField]
private RectTransform popoverTransform = null!;
[SerializeField]
private CanvasGroup popoverCanvasGroup = null!;
[SerializeField]
private TextMeshProUGUI popoverLabel = null!;
private void Awake()
{
this.AssertAllFieldsAreSerialized(typeof(PopoverLayer));
this.MustGetComponent(out myRect);
HidePopover();
}
public void HidePopover()
{
popoverCanvasGroup.alpha = 0;
}
public void ShowPopover(RectTransform target, string text)
{
popoverLabel.SetText(text);
// Calculate world-space rect of the target
// and the popover label itself
Vector2 targetSize = target.rect.size * target.lossyScale;
Vector2 labelSize = popoverTransform.rect.size * popoverTransform.lossyScale;
var targetWorldRect = new Rect((Vector2) target.position - (targetSize * target.pivot), targetSize);
var labelRect = new Rect((Vector2) popoverTransform.position - (labelSize * popoverTransform.pivot), labelSize);
// Determine the middle-right edge of the target
Vector2 popoverTargetLocation = targetWorldRect.center + new Vector2(targetSize.x / 2, 0);
// If the popover will end up being cut off of the screen, then we force it to the left.
if (popoverTargetLocation.x + labelSize.x >= Screen.width)
popoverTargetLocation.x -= (targetSize.x + labelSize.x);
// Ensure we're lining the centre of the label horizontally with the target
popoverTargetLocation.y -= (labelSize.y / 2);
// Apply label pivot to the target position
popoverTargetLocation += (labelSize * popoverTransform.pivot);
// Move the popover
popoverTransform.position = popoverTargetLocation;
// Show it!
popoverCanvasGroup.alpha = 1;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d85257644eec47e3a658ac7021749907
timeCreated: 1677876032

View file

@ -1698,6 +1698,7 @@ GameObject:
- component: {fileID: 3899192569179841376}
- component: {fileID: 5175237916241937564}
- component: {fileID: 4808066111397095584}
- component: {fileID: 8471092644965781531}
m_Layer: 5
m_Name: Terminal Launcher
m_TagString: Untagged
@ -1861,6 +1862,20 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &8471092644965781531
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3894353390075620875}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6a67e7f94fa9438c87aa82d7cee3504d, type: 3}
m_Name:
m_EditorClassIdentifier:
text:
delaySeconds: 0.1
--- !u!1 &4335016399609749900
GameObject:
m_ObjectHideFlags: 0

View file

@ -3,6 +3,7 @@
using System;
using Architecture;
using Player;
using UI.Popovers;
using UI.Widgets;
using UnityEngine;
using UnityEngine.UI;
@ -16,11 +17,13 @@ namespace UI.Shell.Dock
{
[ExecuteInEditMode]
[RequireComponent(typeof(CompositeIconWidget))]
[RequireComponent(typeof(Popover))]
[RequireComponent(typeof(Button))]
public class DockedProgramLauncher : MonoBehaviour
{
private CompositeIconWidget iconWidget = null!;
private Button button = null!;
private Popover popover;
[SerializeField]
private PlayerInstanceHolder player = null!;
@ -35,6 +38,7 @@ namespace UI.Shell.Dock
{
this.MustGetComponent(out iconWidget);
this.MustGetComponent(out button);
this.MustGetComponent(out popover);
}
private void OnEnable()
@ -49,6 +53,16 @@ namespace UI.Shell.Dock
private void Update()
{
if (program == null)
popover.enabled = false;
else
{
if (!popover.enabled)
popover.enabled = true;
popover.Text = program.Name;
}
#if UNITY_EDITOR
if (EditorApplication.isPlaying)
return;
@ -59,6 +73,7 @@ namespace UI.Shell.Dock
else
iconWidget.Icon = program.Icon;
#endif
}
private void OnClick()