Skip to content

Commit

Permalink
Leaderboard Manager 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMCarter committed Sep 29, 2021
1 parent 2d5d2dd commit c4f9564
Show file tree
Hide file tree
Showing 41 changed files with 5,442 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Leaderboard Manager Change Log:

1.0.4

* Asset Changes *
~ Fixed an issue where the display would not throw an error when the limit was updated on the fly.
+ Updated the commenting on all scripts in the asset.


1.0.3

* Asset Changes *
+ Added Get Position method that was requested by a user on our discord server to support.


1.0.2 | Patch 1

* Store Listing Changes *
~ Updated documentation links.


1.0.2

* Store Listing Changes *
- Updated the asset title to remove the "(CG)" characters after the asset name. This has been replaced with "| CG" instead to look a little neater.
- Updated the main asset description to explain more about the asset and its features.
- Updated all links to be correct for the asset.
- Updated to key images to all be the same size as the main key image.
- Updated the asset colour scheme to be more pastel, the old colour was a bit abrupt.

* Asset Changes *
+ Updated the Leaderboard Manager Logo on the asset editor window.
+ Updated commenting on all code.
+ Name spaced all example code into CarterGames.Assets.LeaderboardManager.Example so that the user does not accidently use example code instead of the asset itself.
+ Updated the example script with all method calls in the example scene coming from the script to help new users understand what method is called per button.
+ Updated the example scene to add a new clear file button that resets the leaderbaord file.
+ Added a new method to clear the leaderboard file when called.


1.0.1

+ Updated the asset logo to look better
+ Added an example scene to all users to give the asset a go as well as providing a example to base their use for the asset on.
~ Fixed a bug with the removefromleaderboard method where it would not work as intended.


1.0.0

Original Asset Release.
7 changes: 7 additions & 0 deletions Changelog.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 116 additions & 0 deletions Docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
Documentation is online, follow the link below to view it
Link: https://carter.games/leaderboardmanager


Offline Documentation Copy:


Summary
Contributors: Jonathan Carter
Documentation Valid for Version: 1.0.4
Last Updated: 05/02/2021


Contents
1 � Package Information
2 � Using The Asset
2.1 � Initial Setup
2.2 � The Display Script
3 � Methods
3.1 � Leaderboard Manager Methods
3.2 � Leaderboard Display Methods
4 � Error Messages & Common Problems


1) Package Information
The package has 5 main folders & 11 files:


Editor/Carter Games/Leaderboard Manager: LeaderboardDisplayEditor.cs
Prefabs/Carter Games/Leaderboard Manager/Example: Canvas.prefab, LeaderboardRow.prefab
Resourses/Carter Games/Leaderboard Manager: IconLBM.png
Scenes/Carter Games/Leaderboard Manager/Example: LeaderboardManagerExampleScene.scene
Scripts/Carter Games/Leaderboard Manager: LeaderboardManager.cs, LeaderboardData.cs & LeaderboardDisplay.cs
Scripts/Carter Games/Leaderboard Manager/Example LeaderboardManagerExample.cs
ChangeLog: Shows the changes from previous verisons of the asset.
Readme: Text file that goes over the changelog for the asset.
Docs: Text file that links to here and provides an offline copy of this page.


2) Using The Asset
Initial Setup
If the asset is all imported correctly, you should be good to go without any additional setup. We recommend you import the editor and prefabs as they help with the usability of the asset.
The prefabs provided give you an idea of how to implement you own UI and are only their as an example. It�s a good idea to have your leaderboard on a scroll view so all the entries can be
displayed when loaded, but that is up to you. If you are new to unity or unsure how the asset works, try out the example scene provided with the asset, assuming you imported everything into
your project.


The Display Script

The asset comes with a display script which gives an example of how the leaderboard manager can be used in your game. The provided script has an editor script to make it look a little
neater as well as providing links to this documentation and the discord server. The display object needs to be set to the parent object you wish to add rows to. This should be a UI sorted
group so that added a prefab instance will be visible to the user. The row prefab is the prefab spawned in for each leaderboard entry for your game. You can use the one provided or make
your own, as long as it has the right amount of text componenets in the right order it will work with the display script provided. If you need additional elements you will need to modify
the script to accomidate the changes. The config section is optional but allows you to determine how many entries you want to display. This is useful if you only want to show to top 3 or
top 10 entries for your game. Ticking the box will display a int field for you to enter this into.

The last option controls how the leaderboard is ordered when it is called. You can choose to have it:
Unordered � which displays each entire sin the order they were placed into the leaderboard.
Descending � which displays the entries in highest score first.
Ascending � which does the opposite and shows the entries with the lowest score first.


3) Methods

Leaderboard Manager Methods
All methods in this class are static and can be called from anywhere in your games without a reference to the script.

AddToLeaderboard(string name, float score)
Adds the name and score to the leaderboard via a leaderboarddata instance.

RemoveEntryFromLeaderboard(string playerName, float playerScore)
Removes the entered entry from the leaderboard.

SaveLeaderboardStore(LeaderboardStore _storedData)
Saves the leaderboard, requires a LeaderboardStore which is holds an array of LeaderboardData. A LeaderboardStore can be added to by calling LeaderboardStore.leaderboardData.add(leaderboardData);

LoadLeaderboardStore()
Loads the saved LeaderboardStore from the save file used for the leaderboard.
Returns: LeaderboardStore

LoadLeaderboardData()
Loads the saved LeaderboardData from the save file used for the leaderboard, overload to return an array of leaderboard data instead.
Returns: Array of LeaderboardData

LoadLeaderboardDataDescending()
Loads the leaderboard values in a descending order based on the players scores.
Returns: Array of LeaderboardData sorted in highest score first.

LoadLeaderboardDataAscending()
Loads the leaderboard values in a ascending order based on the players scores.
Returns: Array of LeaderboardData sorted in lowest score first.

ClearLeaderboardData()
Erases the leaderboard data at the file level, this action can�t be reversed!

GetPosition(string playerName, int playerScore, LeaderboardDisplay.DisplayOptions option)
Gets the position of a player based on their name and score values in the order you define.
Returns: Int for the position for the inputted values



Leaderboard Display Methods
Methods in this class require a reference to be called from other scripts.

UpdateLeaderboardDisplay()
Updates the leaderboard display with any new entries.

ClearLeaderboard()
Clears the leaderboard display of all entries but keeps the data in the local file.



4) Error Messages & Common Problems
If you run into a problem or get an error and are unsure, feel free to drop me an email at ([email protected]) and I�ll do my best to help you out.

We don�t have any specific problems that we can forsee, if any become a common question we will be sure to add it here.
7 changes: 7 additions & 0 deletions Docs.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/Carter Games.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/Carter Games/Leaderboard Manager.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

156 changes: 156 additions & 0 deletions Editor/Carter Games/Leaderboard Manager/LeaderboardDisplayEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
using UnityEngine;
using UnityEditor;

/****************************************************************************************************************************
*
* --{ Leaderboard Manager }--
*
* Leaderboard Display Editor Script
* Overrides the default leaderboard display script inspector with this.
*
* Written by:
* Jonathan Carter
* E: [email protected]
* W: https://jonathan.carter.games
*
* Version: 1.0.4
* Last Updated: 05/02/2021 (d/m/y)
*
****************************************************************************************************************************/

namespace CarterGames.Assets.LeaderboardManager
{
/// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/// <summary>
/// Editor Class (*Not Static*) | Edits the inspector for the leaderboard display script
/// </summary>
/// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[CustomEditor(typeof(LeaderboardDisplay))]
public class LeaderboardDisplayEditor : Editor
{
// Reference to LeaderboardDisaply Script
private LeaderboardDisplay display;


/// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/// <summary>
/// Overrides the default inspector for the Leaderboard Display Script
/// Note: this is not required to use the asset, but make it look a little cleaner xD
/// </summary>
/// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public override void OnInspectorGUI()
{
// References to the script
display = (LeaderboardDisplay)target;

GUILayout.Space(10);

// Header display * Start *
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();

// Shows either the Leaderboard Manager Logo or an alternative for if the icon is deleted when you import the package
if (Resources.Load<Texture2D>("Carter Games/Leaderboard Manager/LogoLBM"))
{
if (GUILayout.Button(Resources.Load<Texture2D>("Carter Games/Leaderboard Manager/LogoLBM"), GUIStyle.none, GUILayout.Width(50), GUILayout.Height(50)))
{
GUI.FocusControl(null);
}
}
else
{
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField("Leaderboard Manager", EditorStyles.boldLabel, GUILayout.Width(150));
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}

GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();


GUILayout.Space(5);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField("Leaderboard Display", EditorStyles.boldLabel, GUILayout.Width(140));
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();

EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField("Version: 1.0.4", GUILayout.Width(87.5f));
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();

GUILayout.Space(10);
// Header display * End *



EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Documentation", GUILayout.Width(110f)))
{
Application.OpenURL("https://carter.games/leaderboardmanager");
}
GUI.backgroundColor = Color.cyan;
if (GUILayout.Button("Discord", GUILayout.Width(65f)))
{
Application.OpenURL("https://carter.games/discord");
}
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Report Issue", GUILayout.Width(100f)))
{
Application.OpenURL("https://carter.games/report");
}
GUI.backgroundColor = Color.white;
GUI.color = Color.white;
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();


// Remaining inspector
GUILayout.Space(10);

EditorGUILayout.LabelField("References", EditorStyles.boldLabel);

// reference needed to the display content gameobject.
SerializedProperty displayProp = serializedObject.FindProperty("leaderboardDisplay");
EditorGUILayout.PropertyField(displayProp, new GUIContent("Display Object:"));

// reference needed to the row prefab for new rows.
SerializedProperty rowProp = serializedObject.FindProperty("leaderboardRowPrefab");
EditorGUILayout.PropertyField(rowProp, new GUIContent("Row Prefab:"));

GUILayout.Space(10);

EditorGUILayout.LabelField("Configuration", EditorStyles.boldLabel);

EditorGUILayout.BeginHorizontal();

// Controls how many entires should be shown
SerializedProperty showAmountProp = serializedObject.FindProperty("showSpecificAmount");
EditorGUILayout.LabelField("Show Specific Number Of Entries:", GUILayout.MinWidth(195));
EditorGUILayout.PropertyField(showAmountProp, new GUIContent(""));
serializedObject.ApplyModifiedProperties();
EditorGUILayout.EndHorizontal();

if (showAmountProp.boolValue)
{
SerializedProperty numberToShowProp = serializedObject.FindProperty("numberToShow");
EditorGUILayout.PropertyField(numberToShowProp, new GUIContent("Number To Show:"));
}

GUILayout.Space(10);

EditorGUILayout.LabelField("Layout Options", EditorStyles.boldLabel);

// Controls the display settings
SerializedProperty optionProp = serializedObject.FindProperty("displayChoice");
EditorGUILayout.PropertyField(optionProp, new GUIContent("Order:"));
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Prefabs/Carter Games.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c4f9564

Please sign in to comment.