diff --git a/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/EditorTab.cs b/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/EditorTab.cs index ad32bdc..150bef9 100644 --- a/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/EditorTab.cs +++ b/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/EditorTab.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; +using CarterGames.Assets.LeaderboardManager.Serialization; using UnityEditor; using UnityEngine; @@ -125,7 +126,16 @@ public void DrawTab() EditorGUILayout.BeginHorizontal(); EditorGUILayout.TextField(boards[i].BoardData[j].EntryUuid); EditorGUILayout.TextField(boards[i].BoardData[j].EntryName); - EditorGUILayout.TextField(boards[i].BoardData[j].EntryValue.ToString()); + + if (boards[i].Type.Equals(LeaderboardType.Time)) + { + EditorGUILayout.TextField(((SerializableTime) boards[i].BoardData[j].EntryValue).ToString("dd:hh:mm:ss.fff")); + } + else + { + EditorGUILayout.TextField(boards[i].BoardData[j].EntryValue.ToString()); + } + EditorGUILayout.EndHorizontal(); } diff --git a/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/LegacyTab.cs b/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/LegacyTab.cs index 0e1fa25..bb0e78e 100644 --- a/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/LegacyTab.cs +++ b/Carter Games/Leaderboard Manager/Code/Editor/Custom Editors/Windows/Leaderboard Editor/LegacyTab.cs @@ -388,7 +388,7 @@ private static LegacyBoardStore LoadData(string path) private static void ConvertAndSave(LegacyBoardDataClass legacyBoardDataClass, LeaderboardType convertTo) { LeaderboardManager.Load(); - LeaderboardManager.CreateLeaderboard(legacyBoardDataClass.BoardID); + LeaderboardManager.CreateLeaderboard(legacyBoardDataClass.BoardID, convertTo); foreach (var entry in legacyBoardDataClass.BoardData) { diff --git a/Carter Games/Leaderboard Manager/Code/Editor/Utility/AssetVersionData.cs b/Carter Games/Leaderboard Manager/Code/Editor/Utility/AssetVersionData.cs index 1d7911a..a6d5b54 100644 --- a/Carter Games/Leaderboard Manager/Code/Editor/Utility/AssetVersionData.cs +++ b/Carter Games/Leaderboard Manager/Code/Editor/Utility/AssetVersionData.cs @@ -31,7 +31,7 @@ public static class AssetVersionData /// /// The version number of the asset. /// - public static string VersionNumber => "2.1.0"; + public static string VersionNumber => "2.2.0"; /// @@ -40,6 +40,6 @@ public static class AssetVersionData /// /// Asset owner is in the UK, so its D/M/Y format. /// - public static string ReleaseDate => "14/03/2024"; + public static string ReleaseDate => "31/03/2024"; } } \ No newline at end of file diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Leaderboard.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Leaderboard.cs index f2a6b33..73c2844 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Leaderboard.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Leaderboard.cs @@ -39,6 +39,7 @@ public sealed class Leaderboard ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ [SerializeField] private string boardID; + [SerializeField] private LeaderboardType type; [SerializeField] private List boardData; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -53,6 +54,16 @@ public string Id get => boardID; set => boardID = value; } + + + /// + /// The type the leaderboard is for. + /// + public LeaderboardType Type + { + get => type; + set => type = value; + } /// @@ -69,20 +80,14 @@ public List BoardData ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ /// - /// Blank constructor which just makes a new data list when used... - /// - public Leaderboard() - { - boardData = new List(); - } - - - /// - /// Blank constructor which just makes a new data list when used... + /// Makes a new leaderboard based on the entered data. /// - public Leaderboard(string id) + /// The id to assign. + /// The type of leaderboard to make. + public Leaderboard(string id, LeaderboardType type) { boardID = id; + this.type = type; boardData = new List(); } diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Save/LeaderboardSaveData.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Save/LeaderboardSaveData.cs index 387cbe6..547da64 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Save/LeaderboardSaveData.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Save/LeaderboardSaveData.cs @@ -49,14 +49,7 @@ public class LeaderboardSaveData public LeaderboardSaveData(Leaderboard leaderboard) { id = leaderboard.Id; - - type = leaderboard.GetType().FullName switch - { - var x when x.Contains("Score") => LeaderboardType.Score, - var x when x.Contains("Time") => LeaderboardType.Time, - _ => type - }; - + type = leaderboard.Type; entriesJson = new List(); foreach (var v in leaderboard.BoardData) @@ -75,7 +68,7 @@ var x when x.Contains("Time") => LeaderboardType.Time, /// A leaderboard from the save dat in this class instance. public Leaderboard ToLeaderboard() { - var board = new Leaderboard(id); + var board = new Leaderboard(id, type); board.BoardData = new List(); foreach (var entry in entriesJson) diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/LeaderboardEntryTime.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/LeaderboardEntryTime.cs index 42e8bf9..4b788f5 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/LeaderboardEntryTime.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/LeaderboardEntryTime.cs @@ -126,34 +126,34 @@ public LeaderboardEntryTime(string name, SerializableTime time) /// The formatted string. public string ValueFormatted(DisplayTimeFormat format) { + Debug.Log(EntryValueAsTime.TotalSeconds); + switch (format) { case DisplayTimeFormat.SecondsOnly: - return TimeSpan.FromSeconds(EntryValueAsTime.Seconds).ToString("ss"); + return EntryValueAsTime.TotalSeconds.ToString(CultureInfo.InvariantCulture); case DisplayTimeFormat.MinutesOnly: - return TimeSpan.FromSeconds(EntryValueAsTime.Seconds).ToString("mm"); + return EntryValueAsTime.TotalMinutes.ToString(CultureInfo.InvariantCulture); case DisplayTimeFormat.MinutesSeconds: - return TimeSpan.FromSeconds(EntryValueAsTime.Seconds).ToString("mm':'ss"); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalMinutes}':'ss"); case DisplayTimeFormat.HoursOnly: - return TimeSpan.FromSeconds(EntryValueAsTime.Seconds).ToString("hh"); + return EntryValueAsTime.TotalHours.ToString(CultureInfo.InvariantCulture); case DisplayTimeFormat.HoursMinutes: - return TimeSpan.FromSeconds(EntryValueAsTime.Seconds).ToString("hh':'mm"); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalHours}':'mm"); case DisplayTimeFormat.HoursMinutesSeconds: - return TimeSpan.FromSeconds(EntryValueAsTime.Seconds).ToString("hh':'mm':'ss"); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalHours}':'mm':'ss"); case DisplayTimeFormat.MillisecondsOnly: - return TimeSpan.FromMilliseconds(EntryValueAsTime.Seconds).ToString("fff"); + return EntryValueAsTime.TotalMilliSeconds.ToString(CultureInfo.InvariantCulture); case DisplayTimeFormat.SecondsMilliseconds: - return TimeSpan.FromMilliseconds(EntryValueAsTime.Seconds).ToString("ss':'fff"); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalSeconds}'.'fff"); case DisplayTimeFormat.MinutesSecondsMilliseconds: - return TimeSpan.FromMilliseconds(EntryValueAsTime.Seconds) - .ToString("mm':'ss':'fff"); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalMinutes}':'ss'.'fff"); case DisplayTimeFormat.HoursMinutesSecondsMilliseconds: - return TimeSpan.FromMilliseconds(EntryValueAsTime.Seconds) - .ToString("hh':'mm':'ss':'fff"); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalHours}':'mm':'ss'.'fff"); case DisplayTimeFormat.Unassigned: default: - LbmLogs.Normal("[LeaderboardEntryTime] No valid time format selected."); - return (EntryValueAsTime.Seconds.ToString(CultureInfo.InvariantCulture)); + LbmLogger.Normal("[LeaderboardEntryTime] No valid time format selected."); + return EntryValueAsTime.ToString($"{EntryValueAsTime.TotalHours}':'mm':'ss"); } } } diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/Serialization/SerializableTime.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/Serialization/SerializableTime.cs index 117eccb..a5d13db 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/Serialization/SerializableTime.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Data/Time/Serialization/SerializableTime.cs @@ -22,6 +22,7 @@ */ using System; +using System.Globalization; using UnityEngine; namespace CarterGames.Assets.LeaderboardManager.Serialization @@ -36,6 +37,12 @@ public struct SerializableTime | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + public const long TicksPerMillisecond = 10000; + public const long TicksPerSecond = 10000000; + public const long TicksPerMinute = 600000000; + public const long TicksPerHour = 36000000000; + public const long TicksPerDay = 864000000000; + [SerializeField] private int days; [SerializeField] private int hours; [SerializeField] private int minutes; @@ -81,37 +88,37 @@ public struct SerializableTime /// /// The ticks stored in the time value. /// - public long Ticks => ticks; + public long Ticks => GetTicks(); /// /// The total number of days stored. /// - public double TotalDays => TimeSpan.FromTicks(ticks).TotalDays; + public double TotalDays => Math.Floor(TimeSpan.FromTicks(Ticks).TotalDays); /// /// The total number of hours stored. /// - public double TotalHours => TimeSpan.FromTicks(ticks).TotalHours; + public double TotalHours => Math.Floor(TimeSpan.FromTicks(Ticks).TotalHours); /// /// The total number of minutes stored. /// - public double TotalMinutes => TimeSpan.FromTicks(ticks).TotalMinutes; + public double TotalMinutes => Math.Floor(TimeSpan.FromTicks(Ticks).TotalMinutes); /// /// The total number of seconds stored. /// - public double TotalSeconds => TimeSpan.FromTicks(ticks).TotalSeconds; + public double TotalSeconds => Math.Floor(TimeSpan.FromTicks(Ticks).TotalSeconds); /// /// The total number of milliseconds stored. /// - public double TotalMilliSeconds => TimeSpan.FromTicks(ticks).TotalMilliseconds; + public double TotalMilliSeconds => TimeSpan.FromTicks(Ticks).TotalMilliseconds; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Operators @@ -224,5 +231,74 @@ public static SerializableTime FromDateTime(DateTime dateTime) return time; } + + + /// + /// Gets the ticks based on the time data stored. + /// + /// The ticks for this data. + private long GetTicks() + { + if (ticks > 0) return ticks; + + if (milliseconds > 0) + { + ticks += milliseconds * TicksPerMillisecond; + } + + if (seconds > 0) + { + ticks += seconds * TicksPerSecond; + } + + if (minutes > 0) + { + ticks += minutes * TicksPerMinute; + } + + if (hours > 0) + { + ticks += hours * TicksPerHour; + } + + if (days > 0) + { + ticks += days * TicksPerDay; + } + + return ticks; + } + + + public override string ToString() + { + var date = new DateTime(); + date = date.AddTicks(Ticks); + return date.ToString(CultureInfo.InvariantCulture); + } + + + public string ToString(string format) + { + var date = new DateTime(); + date = date.AddTicks(Ticks); + return date.ToString(format, CultureInfo.InvariantCulture); + } + + + public string ToString(IFormatProvider provider) + { + var date = new DateTime(); + date = date.AddTicks(Ticks); + return date.ToString(provider); + } + + + public string ToString(string format, IFormatProvider provider) + { + var date = new DateTime(); + date = date.AddTicks(Ticks); + return date.ToString(format, provider); + } } } \ No newline at end of file diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardDisplay.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardDisplay.cs index c21be99..5d8e2d2 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardDisplay.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardDisplay.cs @@ -91,7 +91,7 @@ public void UpdateDisplay() { if (customisations.StartingAt < 1) { - LbmLogs.Error("[LeaderboardDisplay] Start at index must be greater than or equal to 1."); + LbmLogger.Error("[LeaderboardDisplay] Start at index must be greater than or equal to 1."); return; } @@ -100,7 +100,7 @@ public void UpdateDisplay() switch (DisplayOption) { case DisplayOption.Unassigned: - LbmLogs.Warning("[LeaderboardDisplay] Display option cannot be Unassigned"); + LbmLogger.Warning("[LeaderboardDisplay] Display option cannot be Unassigned"); break; case DisplayOption.Top3Ascending: case DisplayOption.Top3Descending: @@ -163,7 +163,7 @@ private void SpawnRows(int numberToShow) switch (DisplayOption) { case DisplayOption.Unassigned: - LbmLogs.Warning("[LeaderboardDisplay] Display option cannot be Unassigned."); + LbmLogger.Warning("[LeaderboardDisplay] Display option cannot be Unassigned."); break; case DisplayOption.AsWritten: entries = Base.BoardData.ToArray(); diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardEntryDisplayTMP.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardEntryDisplayTMP.cs index f04cd8f..65e740f 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardEntryDisplayTMP.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Display/LeaderboardEntryDisplayTMP.cs @@ -99,7 +99,7 @@ public override void UpdateDisplay(LeaderboardEntry entry, int entryPosition, Le if (HasScore) { - switch (entry.EntryType.FullName) + switch (entry.EntryType.Name) { case nameof(LeaderboardEntryTime): scoreLabel.text = ((LeaderboardEntryTime) entry).ValueFormatted(customisations.TimeFormat); @@ -108,7 +108,6 @@ public override void UpdateDisplay(LeaderboardEntry entry, int entryPosition, Le scoreLabel.text = entry.EntryValue.ToString(); break; } - } gameObject.SetActive(true); diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/LeaderboardManager.cs b/Carter Games/Leaderboard Manager/Code/Runtime/LeaderboardManager.cs index 41ba1c6..d00f0df 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/LeaderboardManager.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/LeaderboardManager.cs @@ -123,11 +123,12 @@ public static bool BoardExists(string boardId) /// Creates a new leaderboard with the id entered... /// /// The id the board should be defined as - public static void CreateLeaderboard(string boardId) + /// The type of board to make. + public static void CreateLeaderboard(string boardId, LeaderboardType boardType) { if (data.Leaderboards.Count <= 0) { - var firstBoard = new Leaderboard(boardId); + var firstBoard = new Leaderboard(boardId, boardType); data.Leaderboards.Add(firstBoard.Id, firstBoard); @@ -137,11 +138,11 @@ public static void CreateLeaderboard(string boardId) if (BoardExists(boardId)) { - LbmLogs.Normal($"[Leaderboard Manager] Unable to create leaderboard with the ID {boardId} as a board of this ID already exists."); + LbmLogger.Normal($"[Leaderboard Manager] Unable to create leaderboard with the ID {boardId} as a board of this ID already exists."); return; } - var newBoard = new Leaderboard(boardId); + var newBoard = new Leaderboard(boardId, boardType); data.Leaderboards.Add(newBoard.Id, newBoard); @@ -153,15 +154,16 @@ public static void CreateLeaderboard(string boardId) /// Gets the leaderboard of the entered id or creates it if it doesn't exist. /// /// The id the board should be defined as or gotten + /// The type of board to make. /// The board either found or just created. - public static Leaderboard CreateOrGetLeaderboard(string boardId) + public static Leaderboard CreateOrGetLeaderboard(string boardId, LeaderboardType boardType) { if (BoardExists(boardId)) { return GetLeaderboard(boardId); } - CreateLeaderboard(boardId); + CreateLeaderboard(boardId, boardType); return GetLeaderboard(boardId); } @@ -176,7 +178,7 @@ public static void DeleteLeaderboard(string boardId) if (!BoardExists(boardId)) { - LbmLogs.Normal($"[Leaderboard Manager] Unable to delete leaderboard with the ID {boardId} as there are no board with this ID saved."); + LbmLogger.Normal($"[Leaderboard Manager] Unable to delete leaderboard with the ID {boardId} as there are no board with this ID saved."); return; } @@ -194,7 +196,7 @@ public static void ClearLeaderboard(string boardId) { if (!BoardExists(boardId)) { - LbmLogs.Normal($"[Leaderboard Manager] Unable to clear leaderboard with the ID {boardId} as there are no board with this ID saved."); + LbmLogger.Normal($"[Leaderboard Manager] Unable to clear leaderboard with the ID {boardId} as there are no board with this ID saved."); return; } @@ -253,7 +255,7 @@ public static Leaderboard GetLeaderboard(string boardId) return data.Leaderboards[boardId]; } - LbmLogs.Normal($"[Leaderboard Manager] Unable to find leaderboard with the ID {boardId} as a board of this ID doesn't exists."); + LbmLogger.Normal($"[Leaderboard Manager] Unable to find leaderboard with the ID {boardId} as a board of this ID doesn't exists."); return null; } @@ -263,11 +265,11 @@ public static Leaderboard GetLeaderboard(string boardId) /// /// The board to add to /// the data to add - public static void AddEntryToBoard(string boardId, LeaderboardEntry entry) + public static void AddEntryToBoard(string boardId, LeaderboardType type, LeaderboardEntry entry) { if (!BoardExists(boardId)) { - CreateLeaderboard(boardId); + CreateLeaderboard(boardId, type); GetLeaderboard(boardId).AddEntry(entry); Save(); return; diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogs.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogger.cs similarity index 99% rename from Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogs.cs rename to Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogger.cs index 5e32fab..b5b1fe9 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogs.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogger.cs @@ -28,7 +28,7 @@ namespace CarterGames.Assets.LeaderboardManager /// /// A logging class for messages within the asset. /// - public static class LbmLogs + public static class LbmLogger { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Constants diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogs.cs.meta b/Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogger.cs.meta similarity index 100% rename from Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogs.cs.meta rename to Carter Games/Leaderboard Manager/Code/Runtime/Logger/LbmLogger.cs.meta diff --git a/Carter Games/Leaderboard Manager/Code/Runtime/Patches/Legacy Save File Upgrade/LegacyLeaderboardDataHandler.cs b/Carter Games/Leaderboard Manager/Code/Runtime/Patches/Legacy Save File Upgrade/LegacyLeaderboardDataHandler.cs index 367da67..c99eea9 100644 --- a/Carter Games/Leaderboard Manager/Code/Runtime/Patches/Legacy Save File Upgrade/LegacyLeaderboardDataHandler.cs +++ b/Carter Games/Leaderboard Manager/Code/Runtime/Patches/Legacy Save File Upgrade/LegacyLeaderboardDataHandler.cs @@ -102,7 +102,7 @@ private static void ConvertAndSave(LegacyBoardDataClass legacyBoardDataClass, Le if (LeaderboardManager.BoardExists(legacyBoardDataClass.BoardID)) return; - LeaderboardManager.CreateLeaderboard(legacyBoardDataClass.BoardID); + LeaderboardManager.CreateLeaderboard(legacyBoardDataClass.BoardID, LeaderboardType.Score); foreach (var entry in legacyBoardDataClass.BoardData) { diff --git a/Carter Games/Leaderboard Manager/~Documentation/Carter Games - Leaderboard Manager - 2.2.x Documentation.html b/Carter Games/Leaderboard Manager/~Documentation/Carter Games - Leaderboard Manager - 2.2.x Documentation.html new file mode 100644 index 0000000..4cfac7b --- /dev/null +++ b/Carter Games/Leaderboard Manager/~Documentation/Carter Games - Leaderboard Manager - 2.2.x Documentation.html @@ -0,0 +1,1081 @@ +Leaderboard Manager 2.x Documentation +

Leaderboard Manager 2.x Documentation


+

Revision3
Asset Version2.2.0 or newer
Written ByJ,
Asset Store Pagehttps://assetstore.unity.com/packages/tools/utilities/leaderboard-manager-cg-177291
GitHub Repository https://github.com/CarterGames/LeaderboardManager
Homepagehttps://carter.games/leaderboardmanager/

🌟 Thanks


Thank you for deciding to use my asset for your project. If you like my asset, feel free to leave a ⭐⭐⭐⭐⭐ review! If you find that my asset is not up to scratch or find and issue, please do let me know either via email: hello@carter.games and I will do my best to help you with the issues you are facing. I can’t read minds, so if you don’t speak up, it won’t get fixed 😆

+

⭐ Installation & Settings


+

📔 Guides


+

#️⃣ Scripting





+

⚠️ Errors & Log Messaging


+

+

+

+

+

📙

Installation & updating


+

+

+

+

Checking for the latest version


+

As of version 2.1.0 you can check at anytime to make sure you are on the latest version of the asset by pressing the check for updates button in the settings provider for the asset. If you have the check for updates on load enabled in the settings which will auto-run this check when you load the project up and only display a message if the asset has an update available. This system checks the GitHub page for updates, stores such as the Unity Asset Store can be delayed by 1-3 business days or longer due to their review process.

+

+

Getting the latest version


Asset Store


You’ll first need to add the asset to your account to access it. If you’ve already done this the “Add to My Assets” button will display something like “Open In Unity”.

+

Then, in Unity. Access the “Package Manager” via the “Window” tab in the navbar. From there switch to the “My Assets” view for the packages dropdown. From there you’ll be able to select the Leaderboard Manager and download/import the latest version. Then all you need to do is import all the files in the package and you’ll be good to go.

+

Sometimes updates don’t import correctly due to script changes that Unity’s package system doesn’t detect, like old scripts that need to be removed. If you encounter issues from an update, try a clean install of the asset with no asset files imported and that should fix any issues caused. I’ll try to do the clean up for the asset in editor scripts, but there is no guarantee that it’ll work al the time.

+

GitHub


For GitHub you’ll need to navigate to the latest release and download the package provided in the assets for the release. There will always be a .unitypackage file provided in each release. Then you just import that package into your project. You can also just download the source and copy/paste it into your project for a similar result.

Sometimes updates don’t import correctly due to script changes that Unity’s package system doesn’t detect, like old scripts that need to be removed. If you encounter issues from an update, try a clean install of the asset with no asset files imported and that should fix any issues caused. I’ll try to do the clean up for the asset in editor scripts, but there is no guarantee that it’ll work al the time.

+

Itch


For itchio, just download the asset .unitypackage and import it into your project.

+

Sometimes updates don’t import correctly due to script changes that Unity’s package system doesn’t detect, like old scripts that need to be removed. If you encounter issues from an update, try a clean install of the asset with no asset files imported and that should fix any issues caused. I’ll try to do the clean up for the asset in editor scripts, but there is no guarantee that it’ll work all the time.

+

Installing the latest version


When installing a new version over an existing install there is a chance some error occur from older code. Every effort will be made to mitigate issues between updates in the same major version with editor classes. If you are still getting errors related to the asset or it starts mis-behaving, a clean install may be needed. If there are still issues after a clean install then do get in touch with me (hello@carter.games) and I’ll take a look at the issues you are facing.

Its a good idea to make a new branch or a copy of the project before you make these changes just as a backup in-case stuff goes wrong unexpectedly.

+

Override Install


To add to an existing install, just import the package to the project and that should be it once the script have re-compiled.

+

Clean Install


To do a clean install, remove all code for the asset (ideally without the project open to avoid compilation errors). Then either import the new version into a clean project and copy the files over to your project or import the package in the project directly. You may need to reset the per user settings as well if you get errors after that.

+

+

+

+

+

+

📙

Asset Settings


The leaderboard manager has all of its runtime and editor settings shown in the settings provider for the asset. This can be found in Project Settings → Carter Games → Leaderboard Manager

+

Info Section


The info section displays the version of the asset your are currently using and the date it was released on. If you want to make sure you have the latest version of the asset, you can do so by pressing the Check For Updates button on the far right hand side of this section. A dialogue will appear briefly after you press this button letting you know if you have the latest version or not. If you don’t have the latest, a link will be provided to get the latest update from GitHub.

Note: The check for updates button requires an internet connection to work.

+

+

Settings Explained


Editor Settings


As editor settings are per user settings like tab positions in the editor it makes sense to keep these out of version control with this change. You can reset these settings via the menu item: Tools/Carter Games/Leaderboard Manager/Reset User Editor Settings

+

All of the editor settings are hidden from view as they are settings that should be applied on a per user basis. These can be reset from the navbar menu or from here should you wish. However a few are exposed here you you can toggle them with ease:
SettingDescriptionDefault Value
Update Check On LoadChecks for update on the asset’s GitHub repository when you open the Unity project with the asset in to. You’ll see a dialogue if there is an update.true
Show Debug LogsDefines if the asset throws any intentional logs to the user. Disable to clear up the logs a tad. true

+

Options


SettingDescriptionDefault Value
Save LocationSets the save location of the leaderboards.


Local File:
Saves to a local file on the users system.
Local File
Legacy Convert SettingsA disabled GUI of the conversion settings defined for 2.0.x leaderboard to convert to when detected by the asset. This is only used if legacy data structured boards exist on the users local machine and only runs once.Empty Serialized Dictionary

+

+

+

+

+

📙

Making a leaderboard


Leaderboards are all created at runtime in this asset. To make a leaderboard you’ll need use the ⌨️Leaderboard Manager API in your own code. You can either create a board and then get it at a later point or Create and get the leaderboard at the same time. Some examples below:

+

private void OnEnable()
+{
+		// Creates a board... if it doesn't exist already.
+		if (!LeaderboardManager.BoardExists("Level_01"))
+		{
+				LeaderboardManager.CreateLeaderboard("Level_01", LeaderboardType.Score);
+		}
+
+		// Accesses the made board...
+		var board = LeaderboardManager.GetLeaderboard("Level_01");
+}

API used:

🔳BoardsExists

🔳CreateLeaderboard

🔳GetLeaderboard

+

+

private void OnEnable()
+{
+		// Creates a board if it doesn't exist and then accesses the made board...
+		var board = LeaderboardManager.CreateOrGetLeaderboard("Level_01", LeaderboardType.Score);
+}

API used:

🔳CreateOrGetLeaderboard

+

+

+

+

+

📙

The leaderboard display


The leaderboard display is a component to display the entries of a board at runtime. This is designed as a basic setup. If you need more advanced control, it’ll be easier to make you own solution to display the entries.

+

Leaderboard


VariableDescription
Board IdThe string id of the board you want to display. This can be set at runtime.
Display OptionThe method the board should display as.

+

Display Setup


VariableDescription
Board ParentThe parent gameObject for the rows to spawn under.
Row PrefabThe prefab to spawn for each row of the leaderboard.
Entries To ShowThe number of entries to show. Only applies on certain display options, the field will appear disabled on invalid options.
Start AtThe entry position to start showing at entries from, from the display option selected.

+

Display Customisation


VariableDescription
Show PositionDefines if the position field is used on the entry display or not.
Position PrefixThe prefix before the position number on the entry display. Only used is Show Position is true.
Time Format (Time Display Only)The format the time score value should show as.

+

+

+

+

+

+

📙

Leaderboard entry display


The leaderboard entry display is a script that aids in displaying a leaderboard entry on UI. It replaces an older solution that got the references by index which was more rigid than it needed to be.

The current setup has you referencing the text components yourself with a drag and drop from the inspector instead.

⚠️
Note: You don’t need the reference the position label if you are not displaying it.
⚠️
Note: You can leave any reference blank (null) to not display that data.

+

The asset comes with a setup prefab for both Text Mesh Pro and Unity’s Text UI component. Both in the same layout and structure. It is recommended to make you own copy of this prefab when customising the UI look of each entry on your board.

+

+

+

+

+

📙

The demo scene explained


The example/demo scene is provided to show the asset working. The whole demo folder of the asset can be removed without breaking any other part of the asset.

+

The left side controls the options you can use with the example scene while the right displays the content of the leaderboard. The example scene can display any leaderboard that exists in the manager so you can test your own boards out.

+

Controls


ControlDescription
Board IdThe id of the leaderboard to show and adjust with the other controls.
NameThe name of a new entry to add or remove.
ScoreThe score of an entry to add or remove.
Add To LeaderboardAdds the Name & Score as a new entry in the board defined in the Board Id field.
Remove From LeaderboardRemoves the Name & Score entry from the board defined in the Board Id field.
Update Leaderboard DisplayUpdates the display on the right to show the entries from the board defined in the Board Id field.
Clear Leaderboard DisplayClears the display of entries when called.
Clear LeaderboardClears the leaderboard defined in the Board Id field of any entries.

+

+

+

+

+

+

📙

Save data & locations


+

Save data


Pre 2.1.x the save location for the asset’s leaderboards was:

Application.persisentDataPath/Leaderboards/data.lsf

+

For post 2.1.x the save file location and file type have changed. The new location is now in the root of Application.persisentDataPath instead of an extra directory like so:

Application.persisentDataPath/data.lsf2

+

The file type is also .lsf2 instead of .lsf so you can tell the difference at a glance.

+

+

Save locations


There is currently one 1 save location in the asset. There may be improvements to this in the future with alternatives such as player prefs, cloud & custom locations. A breakdown of the current methods:

+

Local file (Default)


The save will automatically create itself when you first create a leaderboard with the system. The leaderboard save goes to the users computer persistent datapath. For more on this please and to get the location for your system, please see the Unity documentation:

Unity - Scripting API: Application.persistentDataPath
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

+

+

+

+

+

+

📙

Leaderboard editor


The editor is found in the new leaderboard editor window, located under Tools/Carter Games/Leaderboard Manager/Leaderboard Editor This will open the window if it isn’t already. From there select the editor tab to view the leaderboards in the save file.

+

From here you’ll see all the boards with induvidual dropdowns and a delete button. The delete button will remove the board from the save file and this is not recoverable once completed.

+

With a board expanded you’ll be able to view all entries in the order they are saved in the leaderboard, but you’ll not be able to edit the entries themselves. This is currently just a read-only tool to aid with debugging. Further functionality may be added in the future should it be required.

+

+

+

+

+

📙

Porting legacy 2.0.x data


ℹ️
Applies to users who used version 2.0.0 → 2.0.1 of the asset.

With 2.1.x the data structure being saved and the method of saving has been updated to match standards used in the Save Manager asset I also created. Due to this and the limitations of the old structure I updated how it works for this version.

To avoid data loss I’ve made several tools to port the data from an old file into the new system. This does require some setup from you the user, but will let you convert the old data both in the editor for development use and at runtime in new builds of your game. So users won’t lose their progress.

⚠️
Note: This tool currently only works at runtime if the location of the leaderboard save has not been changed from its default Application.persistentDataPath location.

+

Accessing the tools


The tools are in the new leaderboard editor window, located under Tools/Carter Games/Leaderboard Manager/Leaderboard Editor This will open the window if it isn’t already. From there select the legacy tab to access to porting tools.

+

From here you have two tabs available to you:

+

+

Convert Legacy File


To convert a legacy file, first pressed the select file button to open the selection GUI.

This will default to the following path:

Application.persistentDataPath + /Leaderboards/

You should instantly see the old data file here. Just select it to continue. If its not there you will need to find it to select it.

+

Once selected you will be able to see all the boards in the file and some information about them such as the number of entries. You can also toggle the dropdown to see all the entries stored in the board.

+

+

To convert the board to the new format, select the type to convert from the option and then press the convert & save button with the entries dropdown open.

Alternatively you can convert all boards at the press of the convert all button.

+

Setup Runtime Conversions


The runtime tab lets you define the conversion types for any users with existing leaderboard from a 2.0.x version of the asset. This only applies when you play in the editor play mode or in a build of the game. You can add as many entries as needed for the leaderboards you have. This might take a while if you have a lot of boards to go through.

The process is automatic and doesn’t need any prompting to happen. A backup save file of the user’s data is made when performing the conversion just in-case something goes wrong.

⚠️
Note: you shouldn’t try to access the leaderboards until Unity Awake() to ensure this has completed. If a board exists of the same id as an old one during the conversion it will not work.

+

+

+

+

+

+

⌨️

Leaderboard Manager

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


The leaderboard manager is the main class for you to use for the asset. This includes managing the leaderboards and adding/removing entries.

+

+

Technical Docs


Properties


+

Methods


+

+

+

🔴

IsInitialized


+

Declaration


public static bool IsInitialized { get; }

+

Description


Gets if the leaderboard manager is initialized or not, mostly if the save has been loaded. This happens on [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] so it should be initialized before the you need to access it.

+

Example


private void OnEnable()
+{
+		Debug.Log(LeaderboardManager.IsInitialized);
+}

+

+

+

+

🔴

NumberOfBoards


+

Declaration


public static int NumberOfBoards { get; }

+

Description


Gets the total number of leaderboards currently stored in the manager.

+

Example


private void OnEnable()
+{
+		Debug.Log(LeaderboardManager.NumberOfBoards);
+}

+

+

+

+

🔴

AllLeaderboards


+

Declaration


public static SerializableDictionary<string, Leaderboard> AllLeaderboards { get; }

+

Description


Gets all the leaderboards stored in the manager. This is mostly used for editor stuff but you can access it if you need to.

+

Example


private void OnEnable()
+{
+		Debug.Log(LeaderboardManager.AllLeaderboards);
+}

+

+

+

+

🔳

BoardsExists


+

Declaration


public static bool BoardExists(string boardId)

+

Parameters


string boardIdThe id of the leaderboard to find.

+

Description


Returns if there is a leaderboard of the entered id in the manager’s data.

+

Example


private void OnEnable()
+{
+		if (LeaderboardManager.BoardExists("MyLeaderboard")
+		{
+				// Do stuff here...
+		}
+}

+

+

+

+

🔳

CreateLeaderboard


+

Declaration


public static void CreateLeaderboard(string boardId, LeaderboardType boardType)

+

Parameters


string boardIdThe id of the leaderboard to find.
LeaderboardType boardTypeThe type of leaderboard to make.

+

Description


Creates a leaderboard with the entered id if it doesn’t exist already.

+

Example


private void OnEnable()
+{
+		LeaderboardManager.CreateLeaderboard("MyLeaderboard", LeaderboardType.Score);
+}

+

+

+

+

🔳

CreateOrGetLeaderboard


+

Declaration


public static void CreateOrGetLeaderboard(string boardId, LeaderboardType boardType)

+

Parameters


string boardIdThe id of the leaderboard to find.
LeaderboardType boardTypeThe type of leaderboard to make.

+

Description


Creates or get an existing leaderboard with the entered id if it doesn’t exist already.

+

Example


private void OnEnable()
+{
+		var board = LeaderboardManager.CreateOrGetLeaderboard("MyLeaderboard", LeaderboardType.Score);
+}

+

+

+

+

🔳

DeleteLeaderboard


+

Declaration


public static void DeleteLeaderboard(string boardId)

+

Parameters


string boardIdThe id of the leaderboard to find.

+

Description


Deletes the leaderboard of the entered id if it exists.

+

Example


private void OnEnable()
+{
+		LeaderboardManager.DeleteLeaderboard("MyLeaderboard");
+}

+

+

+

+

🔳

ClearLeaderboard


+

Declaration


public static void ClearLeaderboard(string boardId)

+

Parameters


string boardIdThe id of the leaderboard to find.

+

Description


Clears the leaderboard of the entered id when called

+

Example


private void OnEnable()
+{
+		LeaderboardManager.ClearLeaderboard("MyLeaderboard");
+}

+

+

+

+

🔳

ClearAllLeaderboards


+

Declaration


public static void ClearAllLeaderboards()

+

Description


Clears all the leaderboards stored in the asset when called.

+

Example


private void OnEnable()
+{
+		LeaderboardManager.ClearAllLeaderboards();
+}

+

+

+

+

🔳

Save


+

Declaration


public static void Save()

+

Description


Saves all the leaderboards in their current states when called.

+

Example


private void OnEnable()
+{
+		LeaderboardManager.Save();
+}

+

+

+

+

🔳

Load


+

Declaration


public static void Load()

+

Description


Loads all the leaderboards to their latest saved states when called.

+

Example


private void OnEnable()
+{
+		LeaderboardManager.Load();
+}

+

+

+

+

🔳

GetLeaderboard


+

Declaration


public static Leaderboard GetLeaderboard(string boardId)

+

Parameters


string boardIdThe id of the leaderboard to find.

+

Description


Gets the leaderboard of the entered id if it exists in the manager.

+

Example


private void OnEnable()
+{
+		Leaderboard board = LeaderboardManager.GetLeaderboard("MyBoard");
+}

+

+

+

+

🔳

AddEntryToBoard


+

Declaration


public static void AddEntryToBoard(string boardId, LeaderboardEntry entry)

+

Parameters


string boardIdThe id of the leaderboard to find.
LeaderboardEntry entryThe entry to add.

+

Description


Adds an entry to the leaderboard of the entered id. If it doesn’t exist it will add one.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore("John Smith", 100);
+		LeaderboardManager.AddEntryToBoard("MyBoard", entry);
+}

+

+

+

+

🔳

DeleteEntryFromBoard


+

Declaration


public static void DeleteEntryFromBoard(string boardId, LeaderboardEntry entry)
+public static void DeleteEntryFromBoard(string boardId, string name, object value)

+

Parameters


string boardIdThe id of the leaderboard to find.
LeaderboardEntry entryThe entry to add.

+
string boardIdThe id of the leaderboard to find.
string nameThe name to associate with the entry.
object valueThe value of the entry.

+

Description


Deletes the entry from the entered leaderboard if a match is found.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore("John Smith", 100);
+		LeaderboardManager.DeleteEntryFromBoard("MyBoard", entry);
+}

+

+

+

+

⌨️

Leaderboard Data Store

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboardManager

+

Description


The data class that stores all the leaderboards for saving & loading.

+

Technical Docs


Properties


+

Methods


+

+

+

+

🔴

Leaderboards


⚠️
This method is intended for internal use only.

+

Declaration


public SerializableDictionary<string, Leaderboard> Leaderboards { get; set; }

+

Description


Gets/Sets all the leaderboards in the store. You should not alter this directly, instead access it through the 🔴AllLeaderboards if needed.

+

+

+

+

🔴

SavableData


⚠️
This method is intended for internal use only.

+

Declaration


public SerializableDictionary<string, LeaderboardSaveData> SavableData { get; }

+

Description


Gets the leaderboard data in a savable format to be used in the save system of the asset. This is intended only for internal asset use.

+

+

+

+

🔳

LoadFromSaveData


⚠️
This method is intended for internal use only.

+

Declaration


public void LoadFromSaveData(SerializableDictionary<string, LeaderboardSaveData> data)

+

Parameters


SerializableDictionary<string, LeaderboardSaveData> dataThe data to load from.

+

Description


Loads the data into the store for use.

+

+

+

+

⌨️

Leaderboard

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A container class that stores a single leaderboard and all its data.

+

Technical Docs


Properties


+

Methods


+

+

+

+

+

🔴

Id


+

Declaration


public static bool Id { get; set; }

+

Description


Contains the id that the leaderboard is defined as.

+

+

+

+

+

🔴

BoardData


+

Declaration


public static List<LeaderboardEntry> BoardData { get; set; }

+

Description


Gets the data stored in the leaderboard.

+

Example


private void OnEnable()
+{
+		var entries = LeaderboardManager.GetLeaderboard("MyBoard").BoardData;
+}

+

+

+

+

+

🔳

GetEntry


+

Declaration


public LeaderboardEntry GetEntry(string uuid)
+public LeaderboardEntry GetEntry(double id)
+public LeaderboardEntry GetEntry(string name, object score)
+public LeaderboardEntry GetEntry(LeaderboardEntry entry) 

+

Parameters


string uuidThe uuid of the board entry.

+
double idThe id of the board entry.

+
string nameThe name used in the entry.
object scoreThe score value in the entry.

+
LeaderboardEntry entryThe board entry to get.

+

Returns


LeaderboardEntry

The leaderboard entry found from the parameters you entered.

+

Description


Get an entry from the leaderboard.

+

Example


private void OnEnable()
+{
+		// By position id
+		var entry = LeaderboardManager.GetLeaderboard("MyBoard").GetEntry(2);
+
+		// By entry data
+		var entry = LeaderboardManager.GetLeaderboard("MyBoard").GetEntry("John Smith", 100);
+}

+

+

+

+

🔳

GetTop3Ascending


+

Declaration


public LeaderboardEntry[] GetTop3Ascending()

+

Returns


LeaderboardEntry[]

The data found.

+

Description


Gets the top 3 entries of the board in ascending (lowest first) value.

+

Example


private void OnEnable()
+{
+		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTop3Ascending();
+}

+

+

+

+

🔳

GetTopXAscending


+

Declaration


public LeaderboardEntry[] GetTopXAscending(int amount)

+

Parameters


int amountThe number of entries to get.

+

Returns


LeaderboardEntry[]

The data found.

+

Description


Gets the top number of entries of the board in ascending (lowest first) value. You define how many that are grabbed.

+

Example


private void OnEnable()
+{
+		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTopXAscending(5);
+}

+

+

+

+

🔳

GetAllAscending


+

Declaration


public LeaderboardEntry[] GetAllAscending()

+

Returns


LeaderboardEntry[]

The data found.

+

Description


Gets all the entries of the board in ascending (lowest first) value.

+

Example


private void OnEnable()
+{
+		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetAllAscending();
+}

+

+

+

+

🔳

GetTop3Descending


+

Declaration


public LeaderboardEntry[] GetTop3Descending()

+

Returns


LeaderboardEntry[]

The data found.

+

Description


Gets the top 3 entries of the board in descending (highest first) value.

+

Example


private void OnEnable()
+{
+		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTop3Descending();
+}

+

+

+

+

🔳

GetTopXDescending


+

Declaration


public LeaderboardEntry[] GetTopXDescending(int amount)

+

Parameters


int amountThe number of entries to get.

+

Returns


LeaderboardEntry[]

The data found.

+

Description


Gets the top number of entries of the board in descending (highest first) value. You define how many that are grabbed.

+

Example


private void OnEnable()
+{
+		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTopXDescending(5);
+}

+

+

+

+

+

🔳

GetAllDescending


+

Declaration


public LeaderboardEntry[] GetAllDescending()

+

Returns


LeaderboardEntry[]

The data found.

+

Description


Gets all the entries of the board in descending (highest first) value.

+

Example


private void OnEnable()
+{
+		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetAllDescending();
+}

+

+

+

+

+

🔳

AddEntry


+

Declaration


public void AddEntry(LeaderboardEntry entry)

+

Parameters


LeaderboardEntry entryThe board entry to get.

+

Description


Adds a new entry to the leaderboard when called.

+

Example


private void OnEnable()
+{
+		var myEntry = new LeaderboardEntryScore("John Smith, 100);
+		LeaderboardManager.GetLeaderboard("MyLeaderboard").AddEntry(myEntry);
+}

+

+

+

+

🔳

DeleteEntry


+

Declaration


public void DeleteEntry(string name, object score)
+public void DeleteEntry(LeaderboardEntry entry)

+

Parameters


string nameThe name to delete.
object scoreThe score to delete.

+
LeaderboardEntry entryThe entry to delete.

+

Description


Deletes an entry from the leaderboard when called.

+

Example


private void OnEnable()
+{
+		var myEntry = new LeaderboardEntryScore("John Smith, 100);
+		LeaderboardManager.GetLeaderboard("MyLeaderboard").DeleteEntry(myEntry);
+}

+

+

+

+

🔳

Clear


+

Declaration


public void Clear()

+

Description


Clears the leaderboard of all entries when called

+

Example


private void OnEnable()
+{
+		LeaderboardManager.GetLeaderboard("MyLeaderboard").Clear();
+}

+

+

+

+

⌨️

Leaderboard Type

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


Contains the options for the types of leaderboard the asset supports.

+
OptionDescription
ScoreThe normal number based score leaderboard.
TimeA leaderboard with a time value as the score.

+

+

+

+

+

⌨️

Leaderboard Entry

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A container class to store an entry in the leaderboard. This class acts as a base for all entry types. You should inherit from this class when making custom entry types and use it as the class for displays so any type of score will display.

+

Technical Docs


Properties


+

Methods


+

Inheritors


+

+

+

+

🔴

EntryType


+

Declaration


public virtual Type EntryType { get; }

+

Description


Contains the type the of the class for reference internally.

+

+

+

+

🔴

EntryUuid


+

Declaration


public virtual string EntryUuid { get; }

+

Description


Contains the unique identifier for the entry.

+

+

+

+

🔴

EntryId


+

Declaration


public virtual double EntryId { get; }

+

Description


Contains the position identifier for the entry. Normally the order it was entered into the leaderboard.

+

+

+

+

🔴

EntryName


+

Declaration


public virtual string EntryName { get; }

+

Description


Contains the name value for the entry.

+

+

+

+

🔴

EntryValue


+

Declaration


public virtual object EntryValue { get; }

+

Description


Contains the value of the entry, stored as an object so it can be any value and casted as needed.

+

+

+

+

🔳

TryGenerateUuid


+

Declaration


public void TryGenerateUuid()

+

Description


Generates the Uuid for an entry if it doesn’t exist yet. Mainly used for porting old entries.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore();
+		entry.TryGenerateUuid();
+}

+

+

+

+

🔳

Reset


+

Declaration


public void Reset()

+

Description


Resets the entry data to blank values. But keeps the Uuid, Id & Type fields as they are currently set.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore();
+		entry.Reset();
+}

+

+

+

+

🔳

GetSaveData


+

Declaration


public string GetSaveData()

+

Returns


string

The save-able data.

+

Description


Returns the data in the entry as JSON for use in saving.

+

+

+

+

⌨️

Leaderboard Entry Score

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A container class to store an entry in the leaderboard with a number based score as the value of the entry.

+

+

Technical Docs


Properties


+

+

Constructors


+

+

Methods


+

+

+

+

+

🔴

EntryType


+

Declaration


public virtual Type EntryType { get; }

+

Description


Contains the type the of the class for reference internally.

+

+

+

+

🔴

EntryUuid


+

Declaration


public virtual string EntryUuid { get; set; }

+

Description


Contains the unique identifier for the entry.

+

+

+

+

🔴

EntryId


+

Declaration


public virtual double EntryId { get; set; }

+

Description


Contains the position identifier for the entry. Normally the order it was entered into the leaderboard.

+

+

+

+

🔴

EntryName


+

Declaration


public virtual string EntryName { get; set; }

+

Description


Contains the name value for the entry.

+

+

+

+

🔴

EntryValue


+

Declaration


public virtual object EntryValue { get; set; }

+

Description


Contains the value of the entry, stored as an object so it can be any value and casted as needed.

+

+

+

+

🔳

LeaderboardEntryScore


+

Declaration


public LeaderboardEntryScore(string name, double score)

+

Parameters


string nameThe name to set.
double scoreThe score to set.

+

Description


Makes a new entry with the defined values.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore("John Smith", 100);
+}

+

+

+

+

🔳

TryGenerateUuid


+

Declaration


public void TryGenerateUuid()

+

Description


Generates the Uuid for an entry if it doesn’t exist yet. Mainly used for porting old entries.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore("John Smith", 100);
+		entry.TryGenerateUuid();
+}

+

+

+

+

🔳

Reset


+

Declaration


public void Reset()

+

Description


Resets the entry data to blank values. But keeps the Uuid, Id & Type fields as they are currently set.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore("John Smith", 100);
+		entry.Reset();
+}

+

+

+

+

🔳

GetSaveData


+

Declaration


public string GetSaveData()

+

Returns


string

The save-able data.

+

Description


Returns the data in the entry as JSON for use in saving.

+

+

+

+

⌨️

Leaderboard Entry Time

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A container class to store an entry in the leaderboard with a time based score as the value of the entry.

+

+

Technical Docs


Properties


+

Constructors


+

Methods


+

+

+

+

+

+

🔴

EntryType


+

Declaration


public virtual Type EntryType { get; }

+

Description


Contains the type the of the class for reference internally.

+

+

+

+

🔴

EntryUuid


+

Declaration


public virtual string EntryUuid { get; }

+

Description


Contains the unique identifier for the entry.

+

+

+

+

🔴

EntryId


+

Declaration


public virtual double EntryId { get; }

+

Description


Contains the position identifier for the entry. Normally the order it was entered into the leaderboard.

+

+

+

+

🔴

EntryName


+

Declaration


public virtual string EntryName { get; }

+

Description


Contains the name value for the entry.

+

+

+

+

🔴

EntryValue


+

Declaration


public virtual object EntryValue { get; }

+

Description


Contains the value of the entry, stored as an object so it can be any value and casted as needed.

+

+

+

+

🔳

LeaderboardEntryTime


+

Declaration


public LeaderboardEntryTime(string name, SerializableTime time)

+

Parameters


string nameThe name to set.
SerializableTime timeThe time value to set.

+

Description


Makes a new entry with the defined values.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryTime("John Smith", SerializableTime.FromSeconds(60));
+}

+

+

+

+

🔳

TryGenerateUuid


+

Declaration


public void TryGenerateUuid()

+

Description


Generates the Uuid for an entry if it doesn’t exist yet. Mainly used for porting old entries.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore();
+		entry.TryGenerateUuid();
+}

+

+

+

+

🔳

Reset


+

Declaration


public void Reset()

+

Description


Resets the entry data to blank values. But keeps the Uuid, Id & Type fields as they are currently set.

+

Example


private void OnEnable()
+{
+		var entry = new LeaderboardEntryScore();
+		entry.Reset();
+}

+

+

+

+

🔳

GetSaveData


+

Declaration


public string GetSaveData()

+

Returns


string

The save-able data.

+

Description


Returns the data in the entry as JSON for use in saving.

+

+

+

+

⌨️

Serializable Time

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A class to hold a time value for a score of a leaderboard entry.

+

Technical Docs


Properties


+

Methods


+

+

+

+

🔴

Days


+

Declaration


public int Days { get; }

+

Description


Gets the number of days stored in the time value.

+

+

+

+

🔴

Hours


+

Declaration


public int Hours { get; }

+

Description


Gets the number of hours stored in the time value.

+

+

+

+

🔴

Minutes


+

Declaration


public int Minutes { get; }

+

Description


Gets the number of minutes stored in the time value.

+

+

+

+

🔴

Seconds


+

Declaration


public int Seconds { get; }

+

Description


Gets the number of seconds stored in the time value.

+

+

+

+

🔴

Milliseconds


+

Declaration


public int Milliseconds { get; }

+

Description


Gets the number of milliseconds stored in the time value.

+

+

+

+

🔴

Ticks


+

Declaration


public long Ticks { get; }

+

Description


Gets the number of ticks stored in the time value.

+

+

+

+

🔴

TotalDays


+

Declaration


public double TotalDays { get; }

+

Description


Gets the total number of days stored from the time value based on the current tick count stored.

+

+

+

+

🔴

TotalHours


+

Declaration


public double TotalHours { get; }

+

Description


Gets the total number of hours stored from the time value based on the current tick count stored.

+

+

+

+

🔴

TotalMinutes


+

Declaration


public double TotalMinutes { get; }

+

Description


Gets the total number of minutes stored from the time value based on the current tick count stored.

+

+

+

+

🔴

TotalSeconds


+

Declaration


public double TotalSeconds { get; }

+

Description


Gets the total number of seconds stored from the time value based on the current tick count stored.

+

+

+

🔴

TotalMilliseconds


+

Declaration


public double TotalMilliseconds { get; }

+

Description


Gets the total number of milliseconds stored from the time value based on the current tick count stored.

+

+

+

+

🔳

FromSeconds


+

Declaration


public static SerializableTime FromSeconds(double seconds)

+

Parameters


double secondsThe seconds to set from.

+

Returns


SerializableTime

The time setup as requested.

+

Description


Makes a SerializableTime from the seconds entere

+

Example


private void OnEnable()
+{
+		// Makes a SerializableTime for 5 minutes.
+		var time = SerializableTime.FromSeconds(300);
+}

+

+

+

+

🔳

FromTicks


+

Declaration


public static SerializableTime FromTicks(long ticks)

+

Parameters


long ticksThe ticks to set from.

+

Returns


SerializableTime

The time setup as requested.

+

Description


Makes a SerializableTime from the ticks entered.

+

Example


private void OnEnable()
+{
+		// Makes a SerializableTime for 5 minutes.
+		var time = SerializableTime.FromTicks(3000000000);
+}

+

+

+

+

🔳

FromTimeSpan


+

Declaration


public static SerializableTime FromTimeSpan(TimeSpan timeSpan)

+

Parameters


TimeSpan timeSpanThe TimeSpan to set from.

+

Returns


SerializableTime

The time setup as requested.

+

Description


Makes a SerializableTime from the TimeSpan entered.

+

Example


private void OnEnable()
+{
+		// Makes a SerializableTime for 5 minutes.
+		var time = SerializableTime.FromTimeSpan(TimeSpan.FromSeconds(300));
+}

+

+

+

+

🔳

FromDateTime


+

Declaration


public static SerializableTime FromDateTime(DateTime dateTime)

+

Parameters


DateTime dateTimeThe DateTime to set from.

+

Returns


SerializableTime

The time setup as requested.

+

Description


Makes a SerializableTime from the DateTime entered.

+

Example


private void OnEnable()
+{
+		// Makes a SerializableTime for 5 minutes.
+		var time = SerializableTime.FromDateTime(new DateTime(3000000000));
+}

+

+

+

+

⌨️

Leaderboard Display

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A base class to handle displaying entries in your leaderboard. This can be used out of the box in your games. Or you can make you own using this solution as an example.

+

Technical Docs


Fields


+

Properties


+

Methods


+

Inheritors


+

+

+

+

🟩

boardId


+

Declaration


[SerializeField] protected string boardId

+

Description


Holds the board id to display. Use 🔴BoardId to access it out of the script and its inheritors.

+

+

+

+

🟩

displayOption


+

Declaration


[SerializeField] protected DisplayOption displayOption

+

Description


The display option to use for the display. Use 🔴DisplayOption to access it out of the script and its inheritors.

+

+

+

+

🟩

boardParent


+

Declaration


[SerializeField] protected Transform boardParent

+

Description


The parent object for the entries rows to be parented to.

+

+

+

+

🟩

rowPrefab


+

Declaration


[SerializeField] protected LeaderboardEntryDisplayBase rowPrefab

+

Description


The prefab to spawn for each entry of the leaderboard that should be displayed. These are object pooled in the display class to avoid waste.

+

+

+

+

🟩

entriesToShow


+

Declaration


[SerializeField] protected int entriesToShow

+

Description


The number of entries to show on the display. Use 🔴EntriesToShow to access it out of the script and its inheritors.

+

+

+

+

🟩

customisations


+

Declaration


[SerializeField] protected LeaderboardDisplayCustomisations customisations

+

Description


Contains any customizations the user can make to the default display class. The options used vary on the display class being used.

+

+

+

+

🟩

board


+

Declaration


protected Leaderboard board

+

Description


Holds the leaderboard to display. Is setup by the display class.

+

+

+

+

🟩

pool


+

Declaration


protected ObjectPoolGeneric<LeaderboardEntryDisplayBase> pool

+

Description


Holds an object pool of the display prefabs that have been spawned in the world. Spawning additional ones as needed. This uses a custom object pool class which you can use in your stuff if you want to. It can be found under Common in the Runtime folder.

+

+

+

+

🔴

BoardId


+

Declaration


public static bool Id { get; set; }

+

Description


Contains the id that the leaderboard is defined as.

+

+

+

+

🔴

DisplayOption


+

Declaration


public DisplayOption DisplayOption { get; set; }

+

Description


+

+

Example


private void OnEnable()
+{
+		var entries = LeaderboardManager.GetLeaderboard("MyBoard").BoardData;
+}

+

+

+

+

🔴

EntriesToShow


+

Declaration


public int EntriesToShow { get; set; }

+

Description


+

+

Example


private void OnEnable()
+{
+		var entries = LeaderboardManager.GetLeaderboard("MyBoard").BoardData;
+}

+

+

+

+

🔳

UpdateDisplay


+

Declaration


public void UpdateDisplay() 

+

Description


Updates the leaderboard display with the current entries to show.

+

Example


[SerializeField] private LeaderboardDisplay display;
+
+private void OnEnable()
+{
+		display.UpdateDisplay();
+}

+

+

+

+

🔳

ClearDisplay


+

Declaration


public void ClearDisplay() 

+

Description


Clears the display of all entries when called.

+

Example


[SerializeField] private LeaderboardDisplay display;
+
+private void OnEnable()
+{
+		display.ClearDisplay();
+}

+

+

+

+

🔳

UpdateDataOnRows


+

Declaration


protected virtual void UpdateDataOnRows(LeaderboardEntry[] entries, int numberToShow)

+

Parameters


LeaderboardEntry[] entriesThe entries to show.
int numberToShowThe number of entries to show.

+

Description


Updates the visuals with the data in the board.

+

Example


[SerializeField] private LeaderboardDisplay display;
+
+private void OnEnable()
+{
+		var entries = LeaderboardManager.GetLeaderboard("MyBoard").GetAllDescending();
+
+		display.UpdateDataOnRows(entries, 5);
+}

+

+

+

+

⌨️

Leaderboard Display Score

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A variant of the base display class with the options for a score based display specifically.

+

+

+

+

⌨️

Leaderboard Display Time

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A variant of the base display class with the options for a time based display specifically.

+

+

+

⌨️

Display Option

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


Contains the options for the leaderboard display to format as.

+
OptionDescription
UnassignedThe default state.
AsWrittenSet to show the leaderboard in the order the entries were added.
AscendingSet to show the leaderboard in ascending order.
DescendingSet to show the leaderboard in descending order.
Top3AscendingSet to show the leaderboard in ascending order but only the top 3 entries.
Top3DescendingSet to show the leaderboard in descending order but only the top 3 entries.
TopXAscendingSet to show the leaderboard in ascending order but only the top x entries. X is defined elsewhere.
TopXDescendingSet to show the leaderboard in descending order but only the top x entries. X is defined elsewhere.

+

+

+

+

+

⌨️

Display Time Format

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


Contains the options for the leaderboard display to format a time score as.

+
OptionDescription
UnassignedThe default state.
MillisecondsOnlySet to show the milliseconds only.
SecondsOnlySet to show the seconds only.
SecondsMillisecondsSet to show the seconds & milliseconds only.
MinutesOnlySet to show the minutes only.
MinutesSecondsSet to show the minutes & seconds only.
MinutesSecondsMillisecondsSet to show the minutes, seconds & milliseconds only.
HoursOnlySet to show the hours only.
HoursMinutesSet to show the hours & minutes only.
HoursMinutesSecondsSet to show the hours, minutes & seconds only.
HoursMinutesSecondsMillisecondsSet to show the hours, minutes, seconds & milliseconds only.

+

+

+

+

+

⌨️

Leaderboard Entry Display Base

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A class to handle displaying an entry of a leaderboard. This is an abstract class with methods that are called by the display class to populate the entry to show.

+

Technical Docs


Methods


+

Inheritors


+

+

+

+

+

🔳

UpdateDisplay


+

Declaration


public abstract void UpdateDisplay(LeaderboardEntry entry, int entryPosition, LeaderboardDisplayCustomisations customisations)

+

Parameters


LeaderboardEntry entryThe entry to display.
int entryPositionThe position of the entry.
LeaderboardDisplayCustomisations customisationsThe customisations to apply to the entry.

+

Description


Runs the update logic for the entry display when called.

+

Example


[SerializedField] private LeaderboardEntryDisplayTMP scoreDisplay;
+
+
+private void OnEnable()
+{
+		var entry = LeaderboardManager.GetLeaderboard("MyBoard").GetTop3Descending()[0];
+		scoreDisplay.UpdateDisplay(entry, 1, null);
+}

+

+

+

+

🔳

ResetDisplay


+

Declaration


public abstract void ResetDisplay()

+

Description


Runs the reset logic for the entry display when called.

+

Example


[SerializedField] private LeaderboardEntryDisplayTMP scoreDisplay;
+
+
+private void OnEnable()
+{
+		scoreDisplay.ResetDisplay();
+}

+

+

+

+

⌨️

Leaderboard Entry Display Text

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A standard UI implementation of the entry display base class to show the entry with normal Unity UI text components.

+

+

Technical Docs


Properties


+

+

+

+

🔴

IsDisplayingEntry


+

Declaration


public bool IsDisplayingEntry { get; }

+

Description


Gets if the entry display is displaying an entry.

+

+

+

+

🔴

DisplayingEntryBase


+

Declaration


public LeaderboardEntry DisplayingEntryBase { get; }

+

Description


Gets the entry the display is showing as its base LeaderboardEntry class.

+

+

+

+

⌨️

Leaderboard Entry Display TMP

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

+

Description


A Text Mesh Pro implementation of the entry display base class to show the entry with Text Mesh Pro text components.

+

+

Technical Docs


Properties


+

+

+

+

🔴

IsDisplayingEntry


+

Declaration


public bool IsDisplayingEntry { get; }

+

Description


Gets if the entry display is displaying an entry.

+

+

+

+

+

🔴

DisplayingEntryBase


+

Declaration


public LeaderboardEntry DisplayingEntryBase { get; }

+

Description


Gets the entry the display is showing as its base LeaderboardEntry class.

+

+

+

+

Asset Accessor

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboardManager

+

Description


A helper class to access any scriptable object that inherits from the LeaderboardManagerAsset class.

+

Technical Docs


Methods

+

+

+

+

🔳

GetAsset<T>


+

Declaration


public static T GetAsset<T>() where T : LeaderboardManagerAsset

+

Returns


T

The asset found as the type you want it. As long as its inheriting from LeaderboardManagerAsset

+

Description


Gets the asset of the type requested that inherits from LeaderboardManagerAsset

+

Example


private void OnEnable()
+{
+		var settings = AssetAccessor.GetAsset<SettingsAssetRuntime>();
+}

+

+

+

+

🔳

GetAssets<T>


+

Declaration


public static T[] GetAssets<T>() where T : LeaderboardManagerAsset

+

Returns


T[]

The assets found as the type you want it. As long as its inheriting from LeaderboardManagerAsset

+

Description


Gets all the assets of the type requested that inherits from LeaderboardManagerAsset

+

Example


private void OnEnable()
+{
+		var settings = AssetAccessor.GetAssets<SettingsAssetRuntime>()[0];
+}

+

+

+

+

⚠️

Logs


The asset has its own logging setup using the normal Debug.Log in the backend. All logs from that asset that are intentional can be disabled from the settings provided in the Leaderboard Manager’s settings provider. This can be found in Project Settings → Carter Games → Leaderboard Manager under the editor dropdown.

The asset will use all types of logging dependant on the severity of the issue. Any errors will come with a unique error code which will be displayed in the log message if such an issue arises. You can see all these codes on the error codes page.

+

+

+

+

🔴

Known Issues


See latest entries in online copy. Shows any known issues for the asset and their status.


Known Issues

NameStatusAsset VersionEngine VersionFixed Asset Version
🏷️Major time leaderboard issues
Fixed
2.1.0Any supported2.2.0


+

+

\ No newline at end of file diff --git a/Carter Games/Leaderboard Manager/~Documentation/Carter Games - leaderboard manager - 2.1.x Documentation.html.meta b/Carter Games/Leaderboard Manager/~Documentation/Carter Games - Leaderboard Manager - 2.2.x Documentation.html.meta similarity index 75% rename from Carter Games/Leaderboard Manager/~Documentation/Carter Games - leaderboard manager - 2.1.x Documentation.html.meta rename to Carter Games/Leaderboard Manager/~Documentation/Carter Games - Leaderboard Manager - 2.2.x Documentation.html.meta index dca7abb..513ab86 100644 --- a/Carter Games/Leaderboard Manager/~Documentation/Carter Games - leaderboard manager - 2.1.x Documentation.html.meta +++ b/Carter Games/Leaderboard Manager/~Documentation/Carter Games - Leaderboard Manager - 2.2.x Documentation.html.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 405b488687e39654bb9b454ed3f157ce +guid: 9145e9067c232ae40b19865105cd879c TextScriptImporter: externalObjects: {} userData: diff --git a/Carter Games/Leaderboard Manager/~Documentation/Carter Games - leaderboard manager - 2.1.x Documentation.html b/Carter Games/Leaderboard Manager/~Documentation/Carter Games - leaderboard manager - 2.1.x Documentation.html deleted file mode 100644 index bcec73f..0000000 --- a/Carter Games/Leaderboard Manager/~Documentation/Carter Games - leaderboard manager - 2.1.x Documentation.html +++ /dev/null @@ -1,1081 +0,0 @@ -Leaderboard Manager 2.x Documentation -

Leaderboard Manager 2.x Documentation


-

Revision2
Asset Version2.1.0 or newer
Written ByJ,
Asset Store Pagehttps://assetstore.unity.com/packages/tools/utilities/leaderboard-manager-cg-177291
GitHub Repository https://github.com/CarterGames/LeaderboardManager
Homepagehttps://carter.games/leaderboardmanager/

🌟 Thanks


Thank you for deciding to use my asset for your project. If you like my asset, feel free to leave a ⭐⭐⭐⭐⭐ review! If you find that my asset is not up to scratch or find and issue, please do let me know either via email: hello@carter.games and I will do my best to help you with the issues you are facing. I can’t read minds, so if you don’t speak up, it won’t get fixed 😆

-

⭐ Installation & Settings


-

📔 Guides


-

#️⃣ Scripting





-

⚠️ Errors & Log Messaging


-

-

-

-

-

📙

Installation & updating


-

-

-

-

Checking for the latest version


-

As of version 2.1.0 you can check at anytime to make sure you are on the latest version of the asset by pressing the check for updates button in the settings provider for the asset. If you have the check for updates on load enabled in the settings which will auto-run this check when you load the project up and only display a message if the asset has an update available. This system checks the GitHub page for updates, stores such as the Unity Asset Store can be delayed by 1-3 business days or longer due to their review process.

-

-

Getting the latest version


Asset Store


You’ll first need to add the asset to your account to access it. If you’ve already done this the “Add to My Assets” button will display something like “Open In Unity”.

-

Then, in Unity. Access the “Package Manager” via the “Window” tab in the navbar. From there switch to the “My Assets” view for the packages dropdown. From there you’ll be able to select the Leaderboard Manager and download/import the latest version. Then all you need to do is import all the files in the package and you’ll be good to go.

-

Sometimes updates don’t import correctly due to script changes that Unity’s package system doesn’t detect, like old scripts that need to be removed. If you encounter issues from an update, try a clean install of the asset with no asset files imported and that should fix any issues caused. I’ll try to do the clean up for the asset in editor scripts, but there is no guarantee that it’ll work al the time.

-

GitHub


For GitHub you’ll need to navigate to the latest release and download the package provided in the assets for the release. There will always be a .unitypackage file provided in each release. Then you just import that package into your project. You can also just download the source and copy/paste it into your project for a similar result.

Sometimes updates don’t import correctly due to script changes that Unity’s package system doesn’t detect, like old scripts that need to be removed. If you encounter issues from an update, try a clean install of the asset with no asset files imported and that should fix any issues caused. I’ll try to do the clean up for the asset in editor scripts, but there is no guarantee that it’ll work al the time.

-

Itch


For itchio, just download the asset .unitypackage and import it into your project.

-

Sometimes updates don’t import correctly due to script changes that Unity’s package system doesn’t detect, like old scripts that need to be removed. If you encounter issues from an update, try a clean install of the asset with no asset files imported and that should fix any issues caused. I’ll try to do the clean up for the asset in editor scripts, but there is no guarantee that it’ll work all the time.

-

Installing the latest version


When installing a new version over an existing install there is a chance some error occur from older code. Every effort will be made to mitigate issues between updates in the same major version with editor classes. If you are still getting errors related to the asset or it starts mis-behaving, a clean install may be needed. If there are still issues after a clean install then do get in touch with me (hello@carter.games) and I’ll take a look at the issues you are facing.

Its a good idea to make a new branch or a copy of the project before you make these changes just as a backup in-case stuff goes wrong unexpectedly.

-

Override Install


To add to an existing install, just import the package to the project and that should be it once the script have re-compiled.

-

Clean Install


To do a clean install, remove all code for the asset (ideally without the project open to avoid compilation errors). Then either import the new version into a clean project and copy the files over to your project or import the package in the project directly. You may need to reset the per user settings as well if you get errors after that.

-

-

-

-

-

-

📙

Asset Settings


The leaderboard manager has all of its runtime and editor settings shown in the settings provider for the asset. This can be found in Project Settings → Carter Games → Leaderboard Manager

-

Info Section


The info section displays the version of the asset your are currently using and the date it was released on. If you want to make sure you have the latest version of the asset, you can do so by pressing the Check For Updates button on the far right hand side of this section. A dialogue will appear briefly after you press this button letting you know if you have the latest version or not. If you don’t have the latest, a link will be provided to get the latest update from GitHub.

Note: The check for updates button requires an internet connection to work.

-

-

Settings Explained


Editor Settings


As editor settings are per user settings like tab positions in the editor it makes sense to keep these out of version control with this change. You can reset these settings via the menu item: Tools/Carter Games/Leaderboard Manager/Reset User Editor Settings

-

All of the editor settings are hidden from view as they are settings that should be applied on a per user basis. These can be reset from the navbar menu or from here should you wish. However a few are exposed here you you can toggle them with ease:
SettingDescriptionDefault Value
Update Check On LoadChecks for update on the asset’s GitHub repository when you open the Unity project with the asset in to. You’ll see a dialogue if there is an update.true
Show Debug LogsDefines if the asset throws any intentional logs to the user. Disable to clear up the logs a tad. true

-

Options


SettingDescriptionDefault Value
Save LocationSets the save location of the leaderboards.


Local File:
Saves to a local file on the users system.
Local File
Legacy Convert SettingsA disabled GUI of the conversion settings defined for 2.0.x leaderboard to convert to when detected by the asset. This is only used if legacy data structured boards exist on the users local machine and only runs once.Empty Serialized Dictionary

-

-

-

-

-

📙

Making a leaderboard


Leaderboards are all created at runtime in this asset. To make a leaderboard you’ll need use the ⌨️Leaderboard Manager API in your own code. You can either create a board and then get it at a later point or Create and get the leaderboard at the same time. Some examples below:

-

private void OnEnable()
-{
-		// Creates a board... if it doesn't exist already.
-		if (!LeaderboardManager.BoardExists("Level_01"))
-		{
-				LeaderboardManager.CreateLeaderboard("Level_01");
-		}
-
-		// Accesses the made board...
-		var board = LeaderboardManager.GetLeaderboard("Level_01");
-}

API used:

🔳BoardsExists

🔳CreateLeaderboard

🔳GetLeaderboard

-

-

private void OnEnable()
-{
-		// Creates a board if it doesn't exist and then accesses the made board...
-		var board = LeaderboardManager.CreateOrGetLeaderboard("Level_01");
-}

API used:

🔳CreateOrGetLeaderboard

-

-

-

-

-

📙

The leaderboard display


The leaderboard display is a component to display the entries of a board at runtime. This is designed as a basic setup. If you need more advanced control, it’ll be easier to make you own solution to display the entries.

-

Leaderboard


VariableDescription
Board IdThe string id of the board you want to display. This can be set at runtime.
Display OptionThe method the board should display as.

-

Display Setup


VariableDescription
Board ParentThe parent gameObject for the rows to spawn under.
Row PrefabThe prefab to spawn for each row of the leaderboard.
Entries To ShowThe number of entries to show. Only applies on certain display options, the field will appear disabled on invalid options.
Start AtThe entry position to start showing at entries from, from the display option selected.

-

Display Customisation


VariableDescription
Show PositionDefines if the position field is used on the entry display or not.
Position PrefixThe prefix before the position number on the entry display. Only used is Show Position is true.
Time Format (Time Display Only)The format the time score value should show as.

-

-

-

-

-

-

📙

Leaderboard entry display


The leaderboard entry display is a script that aids in displaying a leaderboard entry on UI. It replaces an older solution that got the references by index which was more rigid than it needed to be.

The current setup has you referencing the text components yourself with a drag and drop from the inspector instead.

⚠️
Note: You don’t need the reference the position label if you are not displaying it.
⚠️
Note: You can leave any reference blank (null) to not display that data.

-

The asset comes with a setup prefab for both Text Mesh Pro and Unity’s Text UI component. Both in the same layout and structure. It is recommended to make you own copy of this prefab when customising the UI look of each entry on your board.

-

-

-

-

-

📙

The demo scene explained


The example/demo scene is provided to show the asset working. The whole demo folder of the asset can be removed without breaking any other part of the asset.

-

The left side controls the options you can use with the example scene while the right displays the content of the leaderboard. The example scene can display any leaderboard that exists in the manager so you can test your own boards out.

-

Controls


ControlDescription
Board IdThe id of the leaderboard to show and adjust with the other controls.
NameThe name of a new entry to add or remove.
ScoreThe score of an entry to add or remove.
Add To LeaderboardAdds the Name & Score as a new entry in the board defined in the Board Id field.
Remove From LeaderboardRemoves the Name & Score entry from the board defined in the Board Id field.
Update Leaderboard DisplayUpdates the display on the right to show the entries from the board defined in the Board Id field.
Clear Leaderboard DisplayClears the display of entries when called.
Clear LeaderboardClears the leaderboard defined in the Board Id field of any entries.

-

-

-

-

-

-

📙

Save data & locations


-

Save data


Pre 2.1.x the save location for the asset’s leaderboards was:

Application.persisentDataPath/Leaderboards/data.lsf

-

For post 2.1.x the save file location and file type have changed. The new location is now in the root of Application.persisentDataPath instead of an extra directory like so:

Application.persisentDataPath/data.lsf2

-

The file type is also .lsf2 instead of .lsf so you can tell the difference at a glance.

-

-

Save locations


There is currently one 1 save location in the asset. There may be improvements to this in the future with alternatives such as player prefs, cloud & custom locations. A breakdown of the current methods:

-

Local file (Default)


The save will automatically create itself when you first create a leaderboard with the system. The leaderboard save goes to the users computer persistent datapath. For more on this please and to get the location for your system, please see the Unity documentation:

Unity - Scripting API: Application.persistentDataPath
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

-

-

-

-

-

-

📙

Leaderboard editor


The editor is found in the new leaderboard editor window, located under Tools/Carter Games/Leaderboard Manager/Leaderboard Editor This will open the window if it isn’t already. From there select the editor tab to view the leaderboards in the save file.

-

From here you’ll see all the boards with induvidual dropdowns and a delete button. The delete button will remove the board from the save file and this is not recoverable once completed.

-

With a board expanded you’ll be able to view all entries in the order they are saved in the leaderboard, but you’ll not be able to edit the entries themselves. This is currently just a read-only tool to aid with debugging. Further functionality may be added in the future should it be required.

-

-

-

-

-

📙

Porting legacy 2.0.x data


ℹ️
Applies to users who used version 2.0.0 → 2.0.1 of the asset.

With 2.1.x the data structure being saved and the method of saving has been updated to match standards used in the Save Manager asset I also created. Due to this and the limitations of the old structure I updated how it works for this version.

To avoid data loss I’ve made several tools to port the data from an old file into the new system. This does require some setup from you the user, but will let you convert the old data both in the editor for development use and at runtime in new builds of your game. So users won’t lose their progress.

⚠️
Note: This tool currently only works at runtime if the location of the leaderboard save has not been changed from its default Application.persistentDataPath location.

-

Accessing the tools


The tools are in the new leaderboard editor window, located under Tools/Carter Games/Leaderboard Manager/Leaderboard Editor This will open the window if it isn’t already. From there select the legacy tab to access to porting tools.

-

From here you have two tabs available to you:

-

-

Convert Legacy File


To convert a legacy file, first pressed the select file button to open the selection GUI.

This will default to the following path:

Application.persistentDataPath + /Leaderboards/

You should instantly see the old data file here. Just select it to continue. If its not there you will need to find it to select it.

-

Once selected you will be able to see all the boards in the file and some information about them such as the number of entries. You can also toggle the dropdown to see all the entries stored in the board.

-

-

To convert the board to the new format, select the type to convert from the option and then press the convert & save button with the entries dropdown open.

Alternatively you can convert all boards at the press of the convert all button.

-

Setup Runtime Conversions


The runtime tab lets you define the conversion types for any users with existing leaderboard from a 2.0.x version of the asset. This only applies when you play in the editor play mode or in a build of the game. You can add as many entries as needed for the leaderboards you have. This might take a while if you have a lot of boards to go through.

The process is automatic and doesn’t need any prompting to happen. A backup save file of the user’s data is made when performing the conversion just in-case something goes wrong.

⚠️
Note: you shouldn’t try to access the leaderboards until Unity Awake() to ensure this has completed. If a board exists of the same id as an old one during the conversion it will not work.

-

-

-

-

-

-

⌨️

Leaderboard Manager

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


The leaderboard manager is the main class for you to use for the asset. This includes managing the leaderboards and adding/removing entries.

-

-

Technical Docs


Properties


-

Methods


-

-

-

🔴

IsInitialized


-

Declaration


public static bool IsInitialized { get; }

-

Description


Gets if the leaderboard manager is initialized or not, mostly if the save has been loaded. This happens on [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] so it should be initialized before the you need to access it.

-

Example


private void OnEnable()
-{
-		Debug.Log(LeaderboardManager.IsInitialized);
-}

-

-

-

-

🔴

NumberOfBoards


-

Declaration


public static int NumberOfBoards { get; }

-

Description


Gets the total number of leaderboards currently stored in the manager.

-

Example


private void OnEnable()
-{
-		Debug.Log(LeaderboardManager.NumberOfBoards);
-}

-

-

-

-

🔴

AllLeaderboards


-

Declaration


public static SerializableDictionary<string, Leaderboard> AllLeaderboards { get; }

-

Description


Gets all the leaderboards stored in the manager. This is mostly used for editor stuff but you can access it if you need to.

-

Example


private void OnEnable()
-{
-		Debug.Log(LeaderboardManager.AllLeaderboards);
-}

-

-

-

-

🔳

BoardsExists


-

Declaration


public static bool BoardExists(string boardId)

-

Parameters


string boardIdThe id of the leaderboard to find.

-

Description


Returns if there is a leaderboard of the entered id in the manager’s data.

-

Example


private void OnEnable()
-{
-		if (LeaderboardManager.BoardExists("MyLeaderboard")
-		{
-				// Do stuff here...
-		}
-}

-

-

-

-

🔳

CreateLeaderboard


-

Declaration


public static void CreateLeaderboard(string boardId)

-

Parameters


string boardIdThe id of the leaderboard to find.

-

Description


Creates a leaderboard with the entered id if it doesn’t exist already.

-

Example


private void OnEnable()
-{
-		LeaderboardManager.CreateLeaderboard("MyLeaderboard");
-}

-

-

-

-

🔳

CreateOrGetLeaderboard


-

Declaration


public static void CreateOrGetLeaderboard(string boardId)

-

Parameters


string boardIdThe id of the leaderboard to find.

-

Description


Creates or get an existing leaderboard with the entered id if it doesn’t exist already.

-

Example


private void OnEnable()
-{
-		var board = LeaderboardManager.CreateOrGetLeaderboard("MyLeaderboard");
-}

-

-

-

-

🔳

DeleteLeaderboard


-

Declaration


public static void DeleteLeaderboard(string boardId)

-

Parameters


string boardIdThe id of the leaderboard to find.

-

Description


Deletes the leaderboard of the entered id if it exists.

-

Example


private void OnEnable()
-{
-		LeaderboardManager.DeleteLeaderboard("MyLeaderboard");
-}

-

-

-

-

🔳

ClearLeaderboard


-

Declaration


public static void ClearLeaderboard(string boardId)

-

Parameters


string boardIdThe id of the leaderboard to find.

-

Description


Clears the leaderboard of the entered id when called

-

Example


private void OnEnable()
-{
-		LeaderboardManager.ClearLeaderboard("MyLeaderboard");
-}

-

-

-

-

🔳

ClearAllLeaderboards


-

Declaration


public static void ClearAllLeaderboards()

-

Description


Clears all the leaderboards stored in the asset when called.

-

Example


private void OnEnable()
-{
-		LeaderboardManager.ClearAllLeaderboards();
-}

-

-

-

-

🔳

Save


-

Declaration


public static void Save()

-

Description


Saves all the leaderboards in their current states when called.

-

Example


private void OnEnable()
-{
-		LeaderboardManager.Save();
-}

-

-

-

-

🔳

Load


-

Declaration


public static void Load()

-

Description


Loads all the leaderboards to their latest saved states when called.

-

Example


private void OnEnable()
-{
-		LeaderboardManager.Load();
-}

-

-

-

-

🔳

GetLeaderboard


-

Declaration


public static Leaderboard GetLeaderboard(string boardId)

-

Parameters


string boardIdThe id of the leaderboard to find.

-

Description


Gets the leaderboard of the entered id if it exists in the manager.

-

Example


private void OnEnable()
-{
-		Leaderboard board = LeaderboardManager.GetLeaderboard("MyBoard");
-}

-

-

-

-

🔳

AddEntryToBoard


-

Declaration


public static void AddEntryToBoard(string boardId, LeaderboardEntry entry)

-

Parameters


string boardIdThe id of the leaderboard to find.
LeaderboardEntry entryThe entry to add.

-

Description


Adds an entry to the leaderboard of the entered id. If it doesn’t exist it will add one.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore("John Smith", 100);
-		LeaderboardManager.AddEntryToBoard("MyBoard", entry);
-}

-

-

-

-

🔳

DeleteEntryFromBoard


-

Declaration


public static void DeleteEntryFromBoard(string boardId, LeaderboardEntry entry)
-public static void DeleteEntryFromBoard(string boardId, string name, object value)

-

Parameters


string boardIdThe id of the leaderboard to find.
LeaderboardEntry entryThe entry to add.

-
string boardIdThe id of the leaderboard to find.
string nameThe name to associate with the entry.
object valueThe value of the entry.

-

Description


Deletes the entry from the entered leaderboard if a match is found.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore("John Smith", 100);
-		LeaderboardManager.DeleteEntryFromBoard("MyBoard", entry);
-}

-

-

-

-

⌨️

Leaderboard Data Store

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboardManager

-

Description


The data class that stores all the leaderboards for saving & loading.

-

Technical Docs


Properties


-

Methods


-

-

-

-

🔴

Leaderboards


⚠️
This method is intended for internal use only.

-

Declaration


public SerializableDictionary<string, Leaderboard> Leaderboards { get; set; }

-

Description


Gets/Sets all the leaderboards in the store. You should not alter this directly, instead access it through the 🔴AllLeaderboards if needed.

-

-

-

-

🔴

SavableData


⚠️
This method is intended for internal use only.

-

Declaration


public SerializableDictionary<string, LeaderboardSaveData> SavableData { get; }

-

Description


Gets the leaderboard data in a savable format to be used in the save system of the asset. This is intended only for internal asset use.

-

-

-

-

🔳

LoadFromSaveData


⚠️
This method is intended for internal use only.

-

Declaration


public void LoadFromSaveData(SerializableDictionary<string, LeaderboardSaveData> data)

-

Parameters


SerializableDictionary<string, LeaderboardSaveData> dataThe data to load from.

-

Description


Loads the data into the store for use.

-

-

-

-

⌨️

Leaderboard

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A container class that stores a single leaderboard and all its data.

-

Technical Docs


Properties


-

Methods


-

-

-

-

-

🔴

Id


-

Declaration


public static bool Id { get; set; }

-

Description


Contains the id that the leaderboard is defined as.

-

-

-

-

-

🔴

BoardData


-

Declaration


public static List<LeaderboardEntry> BoardData { get; set; }

-

Description


Gets the data stored in the leaderboard.

-

Example


private void OnEnable()
-{
-		var entries = LeaderboardManager.GetLeaderboard("MyBoard").BoardData;
-}

-

-

-

-

-

🔳

GetEntry


-

Declaration


public LeaderboardEntry GetEntry(string uuid)
-public LeaderboardEntry GetEntry(double id)
-public LeaderboardEntry GetEntry(string name, object score)
-public LeaderboardEntry GetEntry(LeaderboardEntry entry) 

-

Parameters


string uuidThe uuid of the board entry.

-
double idThe id of the board entry.

-
string nameThe name used in the entry.
object scoreThe score value in the entry.

-
LeaderboardEntry entryThe board entry to get.

-

Returns


LeaderboardEntry

The leaderboard entry found from the parameters you entered.

-

Description


Get an entry from the leaderboard.

-

Example


private void OnEnable()
-{
-		// By position id
-		var entry = LeaderboardManager.GetLeaderboard("MyBoard").GetEntry(2);
-
-		// By entry data
-		var entry = LeaderboardManager.GetLeaderboard("MyBoard").GetEntry("John Smith", 100);
-}

-

-

-

-

🔳

GetTop3Ascending


-

Declaration


public LeaderboardEntry[] GetTop3Ascending()

-

Returns


LeaderboardEntry[]

The data found.

-

Description


Gets the top 3 entries of the board in ascending (lowest first) value.

-

Example


private void OnEnable()
-{
-		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTop3Ascending();
-}

-

-

-

-

🔳

GetTopXAscending


-

Declaration


public LeaderboardEntry[] GetTopXAscending(int amount)

-

Parameters


int amountThe number of entries to get.

-

Returns


LeaderboardEntry[]

The data found.

-

Description


Gets the top number of entries of the board in ascending (lowest first) value. You define how many that are grabbed.

-

Example


private void OnEnable()
-{
-		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTopXAscending(5);
-}

-

-

-

-

🔳

GetAllAscending


-

Declaration


public LeaderboardEntry[] GetAllAscending()

-

Returns


LeaderboardEntry[]

The data found.

-

Description


Gets all the entries of the board in ascending (lowest first) value.

-

Example


private void OnEnable()
-{
-		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetAllAscending();
-}

-

-

-

-

🔳

GetTop3Descending


-

Declaration


public LeaderboardEntry[] GetTop3Descending()

-

Returns


LeaderboardEntry[]

The data found.

-

Description


Gets the top 3 entries of the board in descending (highest first) value.

-

Example


private void OnEnable()
-{
-		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTop3Descending();
-}

-

-

-

-

🔳

GetTopXDescending


-

Declaration


public LeaderboardEntry[] GetTopXDescending(int amount)

-

Parameters


int amountThe number of entries to get.

-

Returns


LeaderboardEntry[]

The data found.

-

Description


Gets the top number of entries of the board in descending (highest first) value. You define how many that are grabbed.

-

Example


private void OnEnable()
-{
-		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetTopXDescending(5);
-}

-

-

-

-

-

🔳

GetAllDescending


-

Declaration


public LeaderboardEntry[] GetAllDescending()

-

Returns


LeaderboardEntry[]

The data found.

-

Description


Gets all the entries of the board in descending (highest first) value.

-

Example


private void OnEnable()
-{
-		var data = LeaderboardManager.GetLeaderboard("MyLeaderboard").GetAllDescending();
-}

-

-

-

-

-

🔳

AddEntry


-

Declaration


public void AddEntry(LeaderboardEntry entry)

-

Parameters


LeaderboardEntry entryThe board entry to get.

-

Description


Adds a new entry to the leaderboard when called.

-

Example


private void OnEnable()
-{
-		var myEntry = new LeaderboardEntryScore("John Smith, 100);
-		LeaderboardManager.GetLeaderboard("MyLeaderboard").AddEntry(myEntry);
-}

-

-

-

-

🔳

DeleteEntry


-

Declaration


public void DeleteEntry(string name, object score)
-public void DeleteEntry(LeaderboardEntry entry)

-

Parameters


string nameThe name to delete.
object scoreThe score to delete.

-
LeaderboardEntry entryThe entry to delete.

-

Description


Deletes an entry from the leaderboard when called.

-

Example


private void OnEnable()
-{
-		var myEntry = new LeaderboardEntryScore("John Smith, 100);
-		LeaderboardManager.GetLeaderboard("MyLeaderboard").DeleteEntry(myEntry);
-}

-

-

-

-

🔳

Clear


-

Declaration


public void Clear()

-

Description


Clears the leaderboard of all entries when called

-

Example


private void OnEnable()
-{
-		LeaderboardManager.GetLeaderboard("MyLeaderboard").Clear();
-}

-

-

-

-

⌨️

Leaderboard Type

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


Contains the options for the types of leaderboard the asset supports.

-
OptionDescription
ScoreThe normal number based score leaderboard.
TimeA leaderboard with a time value as the score.

-

-

-

-

-

⌨️

Leaderboard Entry

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A container class to store an entry in the leaderboard. This class acts as a base for all entry types. You should inherit from this class when making custom entry types and use it as the class for displays so any type of score will display.

-

Technical Docs


Properties


-

Methods


-

Inheritors


-

-

-

-

🔴

EntryType


-

Declaration


public virtual Type EntryType { get; }

-

Description


Contains the type the of the class for reference internally.

-

-

-

-

🔴

EntryUuid


-

Declaration


public virtual string EntryUuid { get; }

-

Description


Contains the unique identifier for the entry.

-

-

-

-

🔴

EntryId


-

Declaration


public virtual double EntryId { get; }

-

Description


Contains the position identifier for the entry. Normally the order it was entered into the leaderboard.

-

-

-

-

🔴

EntryName


-

Declaration


public virtual string EntryName { get; }

-

Description


Contains the name value for the entry.

-

-

-

-

🔴

EntryValue


-

Declaration


public virtual object EntryValue { get; }

-

Description


Contains the value of the entry, stored as an object so it can be any value and casted as needed.

-

-

-

-

🔳

TryGenerateUuid


-

Declaration


public void TryGenerateUuid()

-

Description


Generates the Uuid for an entry if it doesn’t exist yet. Mainly used for porting old entries.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore();
-		entry.TryGenerateUuid();
-}

-

-

-

-

🔳

Reset


-

Declaration


public void Reset()

-

Description


Resets the entry data to blank values. But keeps the Uuid, Id & Type fields as they are currently set.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore();
-		entry.Reset();
-}

-

-

-

-

🔳

GetSaveData


-

Declaration


public string GetSaveData()

-

Returns


string

The save-able data.

-

Description


Returns the data in the entry as JSON for use in saving.

-

-

-

-

⌨️

Leaderboard Entry Score

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A container class to store an entry in the leaderboard with a number based score as the value of the entry.

-

-

Technical Docs


Properties


-

-

Constructors


-

-

Methods


-

-

-

-

-

🔴

EntryType


-

Declaration


public virtual Type EntryType { get; }

-

Description


Contains the type the of the class for reference internally.

-

-

-

-

🔴

EntryUuid


-

Declaration


public virtual string EntryUuid { get; set; }

-

Description


Contains the unique identifier for the entry.

-

-

-

-

🔴

EntryId


-

Declaration


public virtual double EntryId { get; set; }

-

Description


Contains the position identifier for the entry. Normally the order it was entered into the leaderboard.

-

-

-

-

🔴

EntryName


-

Declaration


public virtual string EntryName { get; set; }

-

Description


Contains the name value for the entry.

-

-

-

-

🔴

EntryValue


-

Declaration


public virtual object EntryValue { get; set; }

-

Description


Contains the value of the entry, stored as an object so it can be any value and casted as needed.

-

-

-

-

🔳

LeaderboardEntryScore


-

Declaration


public LeaderboardEntryScore(string name, double score)

-

Parameters


string nameThe name to set.
double scoreThe score to set.

-

Description


Makes a new entry with the defined values.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore("John Smith", 100);
-}

-

-

-

-

🔳

TryGenerateUuid


-

Declaration


public void TryGenerateUuid()

-

Description


Generates the Uuid for an entry if it doesn’t exist yet. Mainly used for porting old entries.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore("John Smith", 100);
-		entry.TryGenerateUuid();
-}

-

-

-

-

🔳

Reset


-

Declaration


public void Reset()

-

Description


Resets the entry data to blank values. But keeps the Uuid, Id & Type fields as they are currently set.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore("John Smith", 100);
-		entry.Reset();
-}

-

-

-

-

🔳

GetSaveData


-

Declaration


public string GetSaveData()

-

Returns


string

The save-able data.

-

Description


Returns the data in the entry as JSON for use in saving.

-

-

-

-

⌨️

Leaderboard Entry Time

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A container class to store an entry in the leaderboard with a time based score as the value of the entry.

-

-

Technical Docs


Properties


-

Constructors


-

Methods


-

-

-

-

-

-

🔴

EntryType


-

Declaration


public virtual Type EntryType { get; }

-

Description


Contains the type the of the class for reference internally.

-

-

-

-

🔴

EntryUuid


-

Declaration


public virtual string EntryUuid { get; }

-

Description


Contains the unique identifier for the entry.

-

-

-

-

🔴

EntryId


-

Declaration


public virtual double EntryId { get; }

-

Description


Contains the position identifier for the entry. Normally the order it was entered into the leaderboard.

-

-

-

-

🔴

EntryName


-

Declaration


public virtual string EntryName { get; }

-

Description


Contains the name value for the entry.

-

-

-

-

🔴

EntryValue


-

Declaration


public virtual object EntryValue { get; }

-

Description


Contains the value of the entry, stored as an object so it can be any value and casted as needed.

-

-

-

-

🔳

LeaderboardEntryTime


-

Declaration


public LeaderboardEntryTime(string name, SerializableTime time)

-

Parameters


string nameThe name to set.
SerializableTime timeThe time value to set.

-

Description


Makes a new entry with the defined values.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryTime("John Smith", SerializableTime.FromSeconds(60));
-}

-

-

-

-

🔳

TryGenerateUuid


-

Declaration


public void TryGenerateUuid()

-

Description


Generates the Uuid for an entry if it doesn’t exist yet. Mainly used for porting old entries.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore();
-		entry.TryGenerateUuid();
-}

-

-

-

-

🔳

Reset


-

Declaration


public void Reset()

-

Description


Resets the entry data to blank values. But keeps the Uuid, Id & Type fields as they are currently set.

-

Example


private void OnEnable()
-{
-		var entry = new LeaderboardEntryScore();
-		entry.Reset();
-}

-

-

-

-

🔳

GetSaveData


-

Declaration


public string GetSaveData()

-

Returns


string

The save-able data.

-

Description


Returns the data in the entry as JSON for use in saving.

-

-

-

-

⌨️

Serializable Time

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A class to hold a time value for a score of a leaderboard entry.

-

Technical Docs


Properties


-

Methods


-

-

-

-

🔴

Days


-

Declaration


public int Days { get; }

-

Description


Gets the number of days stored in the time value.

-

-

-

-

🔴

Hours


-

Declaration


public int Hours { get; }

-

Description


Gets the number of hours stored in the time value.

-

-

-

-

🔴

Minutes


-

Declaration


public int Minutes { get; }

-

Description


Gets the number of minutes stored in the time value.

-

-

-

-

🔴

Seconds


-

Declaration


public int Seconds { get; }

-

Description


Gets the number of seconds stored in the time value.

-

-

-

-

🔴

Milliseconds


-

Declaration


public int Milliseconds { get; }

-

Description


Gets the number of milliseconds stored in the time value.

-

-

-

-

🔴

Ticks


-

Declaration


public long Ticks { get; }

-

Description


Gets the number of ticks stored in the time value.

-

-

-

-

🔴

TotalDays


-

Declaration


public double TotalDays { get; }

-

Description


Gets the total number of days stored from the time value based on the current tick count stored.

-

-

-

-

🔴

TotalHours


-

Declaration


public double TotalHours { get; }

-

Description


Gets the total number of hours stored from the time value based on the current tick count stored.

-

-

-

-

🔴

TotalMinutes


-

Declaration


public double TotalMinutes { get; }

-

Description


Gets the total number of minutes stored from the time value based on the current tick count stored.

-

-

-

-

🔴

TotalSeconds


-

Declaration


public double TotalSeconds { get; }

-

Description


Gets the total number of seconds stored from the time value based on the current tick count stored.

-

-

-

🔴

TotalMilliseconds


-

Declaration


public double TotalMilliseconds { get; }

-

Description


Gets the total number of milliseconds stored from the time value based on the current tick count stored.

-

-

-

-

🔳

FromSeconds


-

Declaration


public static SerializableTime FromSeconds(double seconds)

-

Parameters


double secondsThe seconds to set from.

-

Returns


SerializableTime

The time setup as requested.

-

Description


Makes a SerializableTime from the seconds entere

-

Example


private void OnEnable()
-{
-		// Makes a SerializableTime for 5 minutes.
-		var time = SerializableTime.FromSeconds(300);
-}

-

-

-

-

🔳

FromTicks


-

Declaration


public static SerializableTime FromTicks(long ticks)

-

Parameters


long ticksThe ticks to set from.

-

Returns


SerializableTime

The time setup as requested.

-

Description


Makes a SerializableTime from the ticks entered.

-

Example


private void OnEnable()
-{
-		// Makes a SerializableTime for 5 minutes.
-		var time = SerializableTime.FromTicks(3000000000);
-}

-

-

-

-

🔳

FromTimeSpan


-

Declaration


public static SerializableTime FromTimeSpan(TimeSpan timeSpan)

-

Parameters


TimeSpan timeSpanThe TimeSpan to set from.

-

Returns


SerializableTime

The time setup as requested.

-

Description


Makes a SerializableTime from the TimeSpan entered.

-

Example


private void OnEnable()
-{
-		// Makes a SerializableTime for 5 minutes.
-		var time = SerializableTime.FromTimeSpan(TimeSpan.FromSeconds(300));
-}

-

-

-

-

🔳

FromDateTime


-

Declaration


public static SerializableTime FromDateTime(DateTime dateTime)

-

Parameters


DateTime dateTimeThe DateTime to set from.

-

Returns


SerializableTime

The time setup as requested.

-

Description


Makes a SerializableTime from the DateTime entered.

-

Example


private void OnEnable()
-{
-		// Makes a SerializableTime for 5 minutes.
-		var time = SerializableTime.FromDateTime(new DateTime(3000000000));
-}

-

-

-

-

⌨️

Leaderboard Display

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A base class to handle displaying entries in your leaderboard. This can be used out of the box in your games. Or you can make you own using this solution as an example.

-

Technical Docs


Fields


-

Properties


-

Methods


-

Inheritors


-

-

-

-

🟩

boardId


-

Declaration


[SerializeField] protected string boardId

-

Description


Holds the board id to display. Use 🔴BoardId to access it out of the script and its inheritors.

-

-

-

-

🟩

displayOption


-

Declaration


[SerializeField] protected DisplayOption displayOption

-

Description


The display option to use for the display. Use 🔴DisplayOption to access it out of the script and its inheritors.

-

-

-

-

🟩

boardParent


-

Declaration


[SerializeField] protected Transform boardParent

-

Description


The parent object for the entries rows to be parented to.

-

-

-

-

🟩

rowPrefab


-

Declaration


[SerializeField] protected LeaderboardEntryDisplayBase rowPrefab

-

Description


The prefab to spawn for each entry of the leaderboard that should be displayed. These are object pooled in the display class to avoid waste.

-

-

-

-

🟩

entriesToShow


-

Declaration


[SerializeField] protected int entriesToShow

-

Description


The number of entries to show on the display. Use 🔴EntriesToShow to access it out of the script and its inheritors.

-

-

-

-

🟩

customisations


-

Declaration


[SerializeField] protected LeaderboardDisplayCustomisations customisations

-

Description


Contains any customizations the user can make to the default display class. The options used vary on the display class being used.

-

-

-

-

🟩

board


-

Declaration


protected Leaderboard board

-

Description


Holds the leaderboard to display. Is setup by the display class.

-

-

-

-

🟩

pool


-

Declaration


protected ObjectPoolGeneric<LeaderboardEntryDisplayBase> pool

-

Description


Holds an object pool of the display prefabs that have been spawned in the world. Spawning additional ones as needed. This uses a custom object pool class which you can use in your stuff if you want to. It can be found under Common in the Runtime folder.

-

-

-

-

🔴

BoardId


-

Declaration


public static bool Id { get; set; }

-

Description


Contains the id that the leaderboard is defined as.

-

-

-

-

🔴

DisplayOption


-

Declaration


public DisplayOption DisplayOption { get; set; }

-

Description


-

-

Example


private void OnEnable()
-{
-		var entries = LeaderboardManager.GetLeaderboard("MyBoard").BoardData;
-}

-

-

-

-

🔴

EntriesToShow


-

Declaration


public int EntriesToShow { get; set; }

-

Description


-

-

Example


private void OnEnable()
-{
-		var entries = LeaderboardManager.GetLeaderboard("MyBoard").BoardData;
-}

-

-

-

-

🔳

UpdateDisplay


-

Declaration


public void UpdateDisplay() 

-

Description


Updates the leaderboard display with the current entries to show.

-

Example


[SerializeField] private LeaderboardDisplay display;
-
-private void OnEnable()
-{
-		display.UpdateDisplay();
-}

-

-

-

-

🔳

ClearDisplay


-

Declaration


public void ClearDisplay() 

-

Description


Clears the display of all entries when called.

-

Example


[SerializeField] private LeaderboardDisplay display;
-
-private void OnEnable()
-{
-		display.ClearDisplay();
-}

-

-

-

-

🔳

UpdateDataOnRows


-

Declaration


protected virtual void UpdateDataOnRows(LeaderboardEntry[] entries, int numberToShow)

-

Parameters


LeaderboardEntry[] entriesThe entries to show.
int numberToShowThe number of entries to show.

-

Description


Updates the visuals with the data in the board.

-

Example


[SerializeField] private LeaderboardDisplay display;
-
-private void OnEnable()
-{
-		var entries = LeaderboardManager.GetLeaderboard("MyBoard").GetAllDescending();
-
-		display.UpdateDataOnRows(entries, 5);
-}

-

-

-

-

⌨️

Leaderboard Display Score

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A variant of the base display class with the options for a score based display specifically.

-

-

-

-

⌨️

Leaderboard Display Time

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A variant of the base display class with the options for a time based display specifically.

-

-

-

⌨️

Display Option

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


Contains the options for the leaderboard display to format as.

-
OptionDescription
UnassignedThe default state.
AsWrittenSet to show the leaderboard in the order the entries were added.
AscendingSet to show the leaderboard in ascending order.
DescendingSet to show the leaderboard in descending order.
Top3AscendingSet to show the leaderboard in ascending order but only the top 3 entries.
Top3DescendingSet to show the leaderboard in descending order but only the top 3 entries.
TopXAscendingSet to show the leaderboard in ascending order but only the top x entries. X is defined elsewhere.
TopXDescendingSet to show the leaderboard in descending order but only the top x entries. X is defined elsewhere.

-

-

-

-

-

⌨️

Display Time Format

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


Contains the options for the leaderboard display to format a time score as.

-
OptionDescription
UnassignedThe default state.
MillisecondsOnlySet to show the milliseconds only.
SecondsOnlySet to show the seconds only.
SecondsMillisecondsSet to show the seconds & milliseconds only.
MinutesOnlySet to show the minutes only.
MinutesSecondsSet to show the minutes & seconds only.
MinutesSecondsMillisecondsSet to show the minutes, seconds & milliseconds only.
HoursOnlySet to show the hours only.
HoursMinutesSet to show the hours & minutes only.
HoursMinutesSecondsSet to show the hours, minutes & seconds only.
HoursMinutesSecondsMillisecondsSet to show the hours, minutes, seconds & milliseconds only.

-

-

-

-

-

⌨️

Leaderboard Entry Display Base

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A class to handle displaying an entry of a leaderboard. This is an abstract class with methods that are called by the display class to populate the entry to show.

-

Technical Docs


Methods


-

Inheritors


-

-

-

-

-

🔳

UpdateDisplay


-

Declaration


public abstract void UpdateDisplay(LeaderboardEntry entry, int entryPosition, LeaderboardDisplayCustomisations customisations)

-

Parameters


LeaderboardEntry entryThe entry to display.
int entryPositionThe position of the entry.
LeaderboardDisplayCustomisations customisationsThe customisations to apply to the entry.

-

Description


Runs the update logic for the entry display when called.

-

Example


[SerializedField] private LeaderboardEntryDisplayTMP scoreDisplay;
-
-
-private void OnEnable()
-{
-		var entry = LeaderboardManager.GetLeaderboard("MyBoard").GetTop3Descending()[0];
-		scoreDisplay.UpdateDisplay(entry, 1, null);
-}

-

-

-

-

🔳

ResetDisplay


-

Declaration


public abstract void ResetDisplay()

-

Description


Runs the reset logic for the entry display when called.

-

Example


[SerializedField] private LeaderboardEntryDisplayTMP scoreDisplay;
-
-
-private void OnEnable()
-{
-		scoreDisplay.ResetDisplay();
-}

-

-

-

-

⌨️

Leaderboard Entry Display Text

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A standard UI implementation of the entry display base class to show the entry with normal Unity UI text components.

-

-

Technical Docs


Properties


-

-

-

-

🔴

IsDisplayingEntry


-

Declaration


public bool IsDisplayingEntry { get; }

-

Description


Gets if the entry display is displaying an entry.

-

-

-

-

🔴

DisplayingEntryBase


-

Declaration


public LeaderboardEntry DisplayingEntryBase { get; }

-

Description


Gets the entry the display is showing as its base LeaderboardEntry class.

-

-

-

-

⌨️

Leaderboard Entry Display TMP

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboarManager

-

Description


A Text Mesh Pro implementation of the entry display base class to show the entry with Text Mesh Pro text components.

-

-

Technical Docs


Properties


-

-

-

-

🔴

IsDisplayingEntry


-

Declaration


public bool IsDisplayingEntry { get; }

-

Description


Gets if the entry display is displaying an entry.

-

-

-

-

-

🔴

DisplayingEntryBase


-

Declaration


public LeaderboardEntry DisplayingEntryBase { get; }

-

Description


Gets the entry the display is showing as its base LeaderboardEntry class.

-

-

-

-

Asset Accessor

Summary


AssemblyCarterGames.Assets.LeaderboardManager.Runtime
NamespaceCarterGames.Assets.LeaderboardManager

-

Description


A helper class to access any scriptable object that inherits from the LeaderboardManagerAsset class.

-

Technical Docs


Methods

-

-

-

-

🔳

GetAsset<T>


-

Declaration


public static T GetAsset<T>() where T : LeaderboardManagerAsset

-

Returns


T

The asset found as the type you want it. As long as its inheriting from LeaderboardManagerAsset

-

Description


Gets the asset of the type requested that inherits from LeaderboardManagerAsset

-

Example


private void OnEnable()
-{
-		var settings = AssetAccessor.GetAsset<SettingsAssetRuntime>();
-}

-

-

-

-

🔳

GetAssets<T>


-

Declaration


public static T[] GetAssets<T>() where T : LeaderboardManagerAsset

-

Returns


T[]

The assets found as the type you want it. As long as its inheriting from LeaderboardManagerAsset

-

Description


Gets all the assets of the type requested that inherits from LeaderboardManagerAsset

-

Example


private void OnEnable()
-{
-		var settings = AssetAccessor.GetAssets<SettingsAssetRuntime>()[0];
-}

-

-

-

-

⚠️

Logs


The asset has its own logging setup using the normal Debug.Log in the backend. All logs from that asset that are intentional can be disabled from the settings provided in the Leaderboard Manager’s settings provider. This can be found in Project Settings → Carter Games → Leaderboard Manager under the editor dropdown.

The asset will use all types of logging dependant on the severity of the issue. Any errors will come with a unique error code which will be displayed in the log message if such an issue arises. You can see all these codes on the error codes page.

-

-

-

-

🔴

Known Issues


See latest entries in online copy. Shows any known issues for the asset and their status.


-

-

\ No newline at end of file diff --git a/Carter Games/Leaderboard Manager/~Samples/Demo/Scenes/Leaderboard Manager Demo Scene.unity b/Carter Games/Leaderboard Manager/~Samples/Demo/Scenes/Leaderboard Manager Demo Scene.unity index 742100f..937350d 100644 --- a/Carter Games/Leaderboard Manager/~Samples/Demo/Scenes/Leaderboard Manager Demo Scene.unity +++ b/Carter Games/Leaderboard Manager/~Samples/Demo/Scenes/Leaderboard Manager Demo Scene.unity @@ -1790,6 +1790,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: boardId: {fileID: 1511537943} + type: 0 playerName: {fileID: 505065358} playerScore: {fileID: 251582821} --- !u!4 &825885281 @@ -1913,12 +1914,12 @@ MonoBehaviour: boardId: Example displayOption: 1 boardParent: {fileID: 1833917230} - rowPrefab: {fileID: 1667449005708359939, guid: 083a44121b2ae0c40b963257e3514593, type: 3} - entriesToShow: 5 + rowPrefab: {fileID: 7602520312045681682, guid: f39d1e8b6224cde4d906c3065b2d4be6, type: 3} + entriesToShow: 10 showOptions: 0 customisations: startAt: 1 - showPosition: 1 + showPosition: 0 positionPrefix: '#' timeFormat: 0 --- !u!4 &904782689 @@ -1929,7 +1930,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 904782687} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 478.09885, y: 278.1841, z: -4.62691} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Carter Games/Leaderboard Manager/~Samples/Demo/Scripts/ExampleManager.cs b/Carter Games/Leaderboard Manager/~Samples/Demo/Scripts/ExampleManager.cs index bbf873d..3ba11ee 100644 --- a/Carter Games/Leaderboard Manager/~Samples/Demo/Scripts/ExampleManager.cs +++ b/Carter Games/Leaderboard Manager/~Samples/Demo/Scripts/ExampleManager.cs @@ -21,6 +21,8 @@ * THE SOFTWARE. */ +using System; +using CarterGames.Assets.LeaderboardManager.Serialization; using UnityEngine; using UnityEngine.UI; @@ -36,6 +38,7 @@ public sealed class ExampleManager : MonoBehaviour ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ [SerializeField] private InputField boardId; + [SerializeField] private LeaderboardType type; [SerializeField] private InputField playerName; [SerializeField] private InputField playerScore; @@ -50,11 +53,11 @@ public void AddToBoard() { if (string.IsNullOrEmpty(playerName.text) || string.IsNullOrEmpty(playerScore.text)) { - LbmLogs.Normal("[DEMO]: Either the name or score fields were blank, please ensure the fields are filled before using this option."); + LbmLogger.Normal("[DEMO]: Either the name or score fields were blank, please ensure the fields are filled before using this option."); return; } - LeaderboardManager.AddEntryToBoard(boardId.text, new LeaderboardEntryScore(playerName.text, double.Parse(playerScore.text))); + LeaderboardManager.AddEntryToBoard(boardId.text, type, new LeaderboardEntryTime(playerName.text, SerializableTime.FromSeconds(double.Parse(playerScore.text)))); playerName.text = string.Empty; playerScore.text = string.Empty; } @@ -67,7 +70,7 @@ public void RemoveFromBoard() { if (string.IsNullOrEmpty(playerName.text) || string.IsNullOrEmpty(playerScore.text)) { - LbmLogs.Normal("[DEMO]: Either the name or score fields were blank, please ensure the fields are filled before using this option."); + LbmLogger.Normal("[DEMO]: Either the name or score fields were blank, please ensure the fields are filled before using this option."); return; }