(Feat) Add Copy Code button

This commit is contained in:
2026-06-24 20:01:40 +02:00
parent 144b3bfbc4
commit 57a27103e1
11 changed files with 3123 additions and 1307 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 80299aa290487634b857eaaf4d2ca8e2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 14e24ec725ca9d24cacffd55b785086c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: 0e9c47c4d13c79942abc12c577238256
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
Binary file not shown.
+47 -2
View File
@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using DG.Tweening;
using Ashwild.Player;
using Ashwild.Settings;
@@ -35,6 +36,12 @@ namespace Ashwild.UI
[SerializeField] private TMP_Text roomCodeLabel;
[Tooltip("Shown in place of the code when no online session is active.")]
[SerializeField] private string offlinePlaceholder = "—";
[Tooltip("Copies the current session code to the system clipboard when clicked.")]
[SerializeField] private Button copyCodeButton;
[Tooltip("Flashed in place of the code for a moment after a successful copy.")]
[SerializeField] private string copyFeedback = "Copié !";
[Tooltip("How long the copy confirmation stays on screen before the code reappears.")]
[SerializeField] private float copyFeedbackDuration = 1.2f;
#endregion
@@ -45,6 +52,12 @@ namespace Ashwild.UI
/// </summary>
private GameUIManager Game => UIManager.Instance as GameUIManager;
/// <summary>
/// Pending tween that restores the room code label after the copy confirmation; killed
/// before being restarted and on teardown so it never fires on a destroyed label.
/// </summary>
private Tween copyFeedbackTween;
#endregion
#region Unity Lifecycle
@@ -60,6 +73,15 @@ namespace Ashwild.UI
if (inviteButton != null) inviteButton.onClick.AddListener(() => Game?.InviteFriend());
if (quitButton != null) quitButton.onClick.AddListener(() => Game?.QuitToMenu());
if (settingsButton != null) settingsButton.onClick.AddListener(() => UIManager.Instance.OpenPanel<SettingsPanel>());
if (copyCodeButton != null) copyCodeButton.onClick.AddListener(CopySessionCode);
}
/// <summary>
/// Kills the copy-feedback tween so it never restores the label after the panel is gone.
/// </summary>
private void OnDestroy()
{
copyFeedbackTween?.Kill();
}
#endregion
@@ -86,10 +108,33 @@ namespace Ashwild.UI
/// </summary>
private void RefreshRoomCode()
{
copyFeedbackTween?.Kill();
bool hasCode = !string.IsNullOrEmpty(PlayerEvents.SessionCode);
if (roomCodeLabel != null)
roomCodeLabel.text = hasCode ? PlayerEvents.SessionCode : offlinePlaceholder;
if (copyCodeButton != null)
copyCodeButton.interactable = hasCode;
}
/// <summary>
/// Copies the live session code to the system clipboard and briefly flashes a confirmation
/// in the room-code label. Does nothing when no online session is active.
/// </summary>
private void CopySessionCode()
{
string code = PlayerEvents.SessionCode;
if (string.IsNullOrEmpty(code)) return;
GUIUtility.systemCopyBuffer = code;
if (roomCodeLabel == null) return;
string code = PlayerEvents.SessionCode;
roomCodeLabel.text = string.IsNullOrEmpty(code) ? offlinePlaceholder : code;
copyFeedbackTween?.Kill();
roomCodeLabel.text = copyFeedback;
copyFeedbackTween = DOVirtual.DelayedCall(copyFeedbackDuration, () => roomCodeLabel.text = code);
}
#endregion
File diff suppressed because it is too large Load Diff