Goal
To create a tool that simplifies and stardardizes the creation and management of JSON files used for texts/translations in Unity.
Structure
- JSON Manager
- A prefab that has an Editor Script Component that contains the following:
- a text field to input the name of JSON file to create.
- a button to create JSON file.
- A prefab that has an Editor Script Component that contains the following:
- Translatable Object
- A regular C# script to be added to Text GameObjects with text to be stored in an existing JSON file.
- Contains a text field for the ID (string or number most probably) of the text we want to store. (We might want to make this read-only after the data is created within the JSON file)
- Also contains a dropdown menu of existing JSON files for grouping and a button to update the JSON file.
- A regular C# script to be added to Text GameObjects with text to be stored in an existing JSON file.
Functions
- JSON Manager
- On create button pressed
- Takes the name inputted in the text field and creates a JSON file in Assets/StreamingAssets
- On create button pressed
- Translatable Object
- On update button pressed
- Takes information from the Text Component in the GameObject and adds to or updates the corresponding JSON file.
- On Play/Start
- Takes the ID and group name and dynamically updates the text of the Text Component
- On update button pressed
Users
Developers can use this tool to add translation functionality to interactives via Unity.
Translators can easily add translated text to interactive pieces without using Unity.
Usage
- Developers: Download Translatable Package.unitypackage from GitHub.
- Open the package in Unity, then double-click Translatable Package.unitypackage, which will automatically add the package to the Unity project.
Create a JSON File
- Add the "JSON Manager" prefab into your project hierarchy.
- Enter the filename to be used for the JSON file (either with or without the .json extension) in the editor window.
Add Values to a JSON File
- Attach the "Translatable" script component to the Text object you wish to edit. You should see this window in the inspector:
- In the "ID" field, enter the string ID you want to associate with the text value.
- Enter the value you would like to add in the "Text" component field.
- Select the JSON file you wish to edit from the dropdown menu.
- Click the "Update JSON file with text component" button.
Update Values in a JSON File
-
In the "ID" field of the Translatable component, enter the string ID associated with the value you wish to update.
-
In the Text Component field, enter the new text to save in the JSON.
- Select the JSON file you wish to edit from the dropdown menu.
- Click the "Update JSON File with Text Component" button.







