Class TrackedMonoBehaviourObject
Uses JSON to apply variant data to target object.
Inherited Members
Namespace: UnityEngine.Localization.PropertyVariants.TrackedObjects
Syntax
public class TrackedMonoBehaviourObject : JsonSerializerTrackedObject
Examples
This shows how to configure a GameObjectLocalizer to apply changes to a custom
public class MyScript : MonoBehaviour
{
public string myText;
public Color textColor;
void OnGUI()
{
GUI.color = textColor;
GUILayout.Label(myText);
}
}
public static class MyScriptEditor
{
public static void SetupLocalization(MyScript script)
{
var localizer = script.gameObject.AddComponent<GameObjectLocalizer>();
// Gets the Tracked text or creates a new tracker
var trackedScript = localizer.GetTrackedObject<TrackedMonoBehaviourObject>(script);
// Gets the Property Variant for the text or creates a new one
var textVariant = trackedScript.GetTrackedProperty<LocalizedStringProperty>(nameof(MyScript.myText));
textVariant.LocalizedString.SetReference("My String Table Collection", "My Text");
var redVariant = trackedScript.GetTrackedProperty<FloatTrackedProperty>("textColor.r");
var greenVariant = trackedScript.GetTrackedProperty<FloatTrackedProperty>("textColor.g");
var blueVariant = trackedScript.GetTrackedProperty<FloatTrackedProperty>("textColor.b");
// Default to black text
redVariant.SetValue("en", 0);
greenVariant.SetValue("en", 0);
blueVariant.SetValue("en", 0);
// Use Red for French
redVariant.SetValue("fr", 1);
// Use Green for Japanese
greenVariant.SetValue("fr", 1);
// Use white for Arabic
redVariant.SetValue("ar", 1);
greenVariant.SetValue("ar", 1);
blueVariant.SetValue("ar", 1);
}
}
Properties
Changed
Declaration
public UnityEvent Changed { get; }
Property Value
Type | Description |
---|---|
UnityEvent |
Methods
PostApplyTrackedProperties()
Declaration
protected override void PostApplyTrackedProperties()