This is a ranking system using GoogleAppsScript, intended for use with Unity.
There are functions to register and retrieve rankings and delete them on the editor. There is also a function to determine the NG words and to suppress the names of those words.
Please prepare your own list of NG words.
日本語版READMEはこちら
- Unity 2022.3 or later
Maybe it will work before 2022.
- Open Package Manager from Window > Package Manager.
- Click the "+" button > Add package from git URL.
- Enter the following URL:
https://github.com/TsuyoshiUsugi/UnityGASRankingSystem.git
-
Set Up a Google Spreadsheet
- Use a spreadsheet in the
SpreadSheetfolder on Google Drive.
- Use a spreadsheet in the
-
Open Apps Script
-
Paste the Code in Apps Script
- Open the
Ranking.gsfile from theGsScriptsfolder. - Copy and paste the content of
Ranking.gsinto the Apps Script editor.
After pasting the code, set up the following configuration:
const CONFIG = { SPREADSHEET_ID: "Your Sheet ID", SHEETS: { MAIN: "Sheet1", NG_WORDS: "NG Words" } };
- Set SPREADSHEET_ID
- Copy the link to your spreadsheet from "Share."
- Extract the ID from the link, which is the part between
https://docs.google.com/spreadsheets/d/and/edit?usp=sharing.
- Open the
-
Deploy Apps Script
- Click the "Deploy" button in the Apps Script editor.
- Select "New Deployment" and complete the deployment process.
This completes the spreadsheet setup.
-
Add GASManager.prefab to the Scene
- Place the
GASManager.prefabfrom theRuntimefolder into the scene where you want to use the ranking feature.
- Place the
-
Access the GASRankingManager Instance
- Use
GASRankingManager.Instanceto call various functions.
- Use
You can send a player's name and score using the following code:
GASRankingManager.Instance.SendScore(_nameInputField.text, score);- Arguments
name: Player name (stringtype)score: Score (floattype)
You can retrieve and display the score list with the following code:
GASRankingManager.Instance.GetScoreList(GASRankingManager.GetScoreOrder.Descending, list =>
{
foreach (Transform child in _scoreListParent.transform)
{
Destroy(child.gameObject);
}
foreach (var playerData in list)
{
var obj = Instantiate(_scoreListPrefab, _scoreListParent.transform);
obj.GetComponentsInChildren<Text>()[0].text = playerData.Name;
obj.GetComponentsInChildren<Text>()[1].text =
playerData.Score.ToString(CultureInfo.CurrentCulture);
}
}, () => { Debug.LogError("Fail"); });- Arguments
- Score display order (ascending or descending):
GASRankingManager.GetScoreOrder - Success callback (
Action<List<PlayerData>>) - Failure callback (
Action)
- Score display order (ascending or descending):
This concludes the instructions for using the ranking feature.

