Evo UI
Work seamlessly with Evo assets
Overview
Evo Localization integrates seamlessly with Evo UI, allowing you to localize text, tooltips, buttons, and other UI elements easily.
No manual setup is required. Once you import the package, localization features become available across all supported components.
Evo Localization is free for Evo UI owners. Check out Evo UI.
Activate Localization
After importing Evo Localization, all supported Evo UI components will automatically detect the package. A new Localization section will appear inside each component's inspector.
In this section, the Auto Setup button appears in UI components that support localization. Clicking Auto Setup will:
Add the required Localization component
Initialize component for localization
Assign the correct localization handler automatically
You can also add the localization components manually if you prefer, but Auto Setup is recommended.
Localizing Components
There are two ways to localize UI elements depending on the component:
Built-in Key Field
Some Evo UI components include a built-in Localization Key field directly in the inspector.
Examples:
- Tooltip
- Notification
- Modal Window
When a Localization Key is available, simply enter the key used in your localization table.
The component will localize automatically whenever the language changes.
Other Objects
If a UI component does not provide a dedicated key field, use the Localized Object component instead. This component allows you to assign a localization key manually.
This ensures every UI element can be localized, even if it has no built-in support.
Language Selector Sample
Dropdown
Create and attach this script to Evo UI dropdowns, and it will work out of the box.
using System.Collections.Generic;
using UnityEngine;
using Evo.Localization;
using Evo.UI;
[RequireComponent(typeof(Dropdown))]
public class LanguageDropdown : MonoBehaviour
{
[Header("References")]
public Dropdown dropdown;
[Header("Settings")]
public bool showLanguageID = false;
public bool useLocalizedNames = true;
void Start()
{
if (dropdown == null)
{
dropdown = GetComponent<Dropdown>();
}
InitializeDropdown();
}
// Initializes the dropdown with available languages
public void InitializeDropdown()
{
LocalizationSettings settings = LocalizationManager.GetSettings();
if (settings == null || settings.languages == null || settings.languages.Count == 0)
{
Debug.LogError("Localization Settings not found or has no languages!");
return;
}
// Clear existing items
dropdown.ClearAllItems();
// Create list of language items
List<Dropdown.Item> options = new();
int currentLanguageIndex = 0;
for (int i = 0; i < settings.languages.Count; i++)
{
// Fetch language asset
var language = settings.languages[i];
if (language?.target == null) { continue; }
// Format the display name
string displayName = useLocalizedNames ? language.target.localizedName : language.target.languageName;
if (showLanguageID) { displayName = $"{displayName} ({language.target.ID})"; }
// Create the language icon sprite
Sprite displayIcon = null;
if (language.target.icon != null)
{
Texture2D langTexture = language.target.icon;
displayIcon = Sprite.Create(
langTexture,
new Rect(0, 0, langTexture.width, langTexture.height),
new Vector2(0.5f, 0.5f),
100f
);
}
// Add the list items
Dropdown.Item optionData = new(displayName, displayIcon);
options.Add(optionData);
// Check if this is the current language
if (LocalizationManager.GetCurrentLanguage() == language.target) { currentLanguageIndex = i; }
}
// Add item to dropdown
dropdown.AddItems(options.ToArray());
// Set current selection
dropdown.SelectItem(currentLanguageIndex, triggerEvents: false);
// Add listener for value changes
dropdown.onItemSelected.AddListener(LocalizationManager.SetLanguage);
}
}Selector
Create and attach this script to Evo UI selectors, and it will work out of the box.
using System.Collections.Generic;
using UnityEngine;
using Evo.Localization;
using Evo.UI;
[RequireComponent(typeof(Selector))]
public class LanguageSelector : MonoBehaviour
{
[Header("References")]
public Selector selector;
[Header("Settings")]
public bool showLanguageID = false;
public bool useLocalizedNames = true;
void Start()
{
if (selector == null)
{
selector = GetComponent<Selector>();
}
InitializeSelector();
}
// Initializes the dropdown with available languages
public void InitializeSelector())
{
LocalizationSettings settings = LocalizationManager.GetSettings();
if (settings == null || settings.languages == null || settings.languages.Count == 0)
{
Debug.LogError("Localization Settings not found or has no languages!");
return;
}
// Clear existing items
selector.ClearItems();
// Create list of language items
List<Selector.Item> options = new();
int currentLanguageIndex = 0;
for (int i = 0; i < settings.languages.Count; i++)
{
// Fetch language asset
var language = settings.languages[i];
if (language?.target == null) { continue; }
// Format the display name
string displayName = useLocalizedNames ? language.target.localizedName : language.target.languageName;
if (showLanguageID) { displayName = $"{displayName} ({language.target.ID})"; }
// Create the language icon sprite
Sprite displayIcon = null;
if (language.target.icon != null)
{
Texture2D langTexture = language.target.icon;
displayIcon = Sprite.Create(
langTexture,
new Rect(0, 0, langTexture.width, langTexture.height),
new Vector2(0.5f, 0.5f),
100f
);
}
// Add the list items
Selector.Item optionData = new(displayName, displayIcon);
options.Add(optionData);
// Check if this is the current language
if (LocalizationManager.GetCurrentLanguage() == language.target) { currentLanguageIndex = i; }
}
// Add item to dropdown
selector.AddItems(options.ToArray());
// Set current selection
selector.SetSelection(currentLanguageIndex, animated: false);
// Add listener for value changes
selector.onSelectionChanged.AddListener(LocalizationManager.SetLanguage);
}
}