Namespace UnityEngine.Localization.PropertyVariants.TrackedObjects
Classes
JsonSerializerTrackedObject
Uses JSON to apply changes to a tracked object. JSON can only be used with MonoBehaviour and ScriptableObject types.
TrackedLayoutGroup
Uses JSON to apply variant data to UnityEngine.UI.LayoutGroup. Forces a layout rebuild on the target object after applying changes.
TrackedMeshFilter
Tracks and applies variant changes to a MeshFilter.
TrackedMonoBehaviourObject
Uses JSON to apply variant data to target object.
TrackedObject
Provides common Property Variant functionality for a Unity object.
You can inherit from this class to create custom object trackers.
[Serializable]
[DisplayName("Audio Source")]
[CustomTrackedObject(typeof(AudioSource), false)]
public class TrackedAudioSource : TrackedObject
{
public override AsyncOperationHandle ApplyLocale(Locale variantLocale, Locale defaultLocale)
{
var audioClipProperty = GetTrackedProperty("m_audioClip");
if (audioClipProperty == null)
return default;
// Check if the Asset is stored in an Asset Table
if (audioClipProperty is LocalizedAssetProperty localizedAssetProperty &&
localizedAssetProperty.LocalizedObject is LocalizedAudioClip localizedAudioClip)
{
localizedAudioClip.LocaleOverride = variantLocale;
var loadHandle = localizedAudioClip.LoadAssetAsync();
if (loadHandle.IsDone)
AudioClipLoaded(loadHandle);
else
{
loadHandle.Completed += AudioClipLoaded;
return loadHandle;
}
}
// Check if the Asset is stored locally
else if (audioClipProperty is UnityObjectProperty localAssetProperty)
{
if (localAssetProperty.GetValue(variantLocale.Identifier, defaultLocale.Identifier, out var clip))
SetAudioClip(clip as AudioClip);
}
return default;
}
void AudioClipLoaded(AsyncOperationHandle<AudioClip> loadHandle)
{
SetAudioClip(loadHandle.Result);
}
void SetAudioClip(AudioClip clip)
{
var source = (AudioSource)Target;
source.Stop();
source.clip = clip;
if (clip != null)
source.Play();
}
public override bool CanTrackProperty(string propertyPath)
{
// We only care about the Audio clip
return propertyPath == "m_audioClip";
}
}
TrackedRectTransform
Tracks and applies variant changes to a RectTransform.
TrackedTmpDropdown
Uses JSON to apply variant data to TMPro.TMP_Dropdown. Calls TMPro.TMP_Dropdown.RefreshShownValue() on the target object after applying changes.
TrackedTransform
Tracks and applies variant changes to a Transform.
TrackedUGuiDropdown
Uses JSON to apply variant data to UnityEngine.UI.Dropdown. Calls UnityEngine.UI.Dropdown.RefreshShownValue() on the target object after applying changes.
TrackedUGuiGraphic
Uses JSON to apply variant data to UGUI UnityEngine.UI.Graphic instances. Calls UnityEngine.UI.Graphic.SetAllDirty() on the target object after applying changes.
Enums
JsonSerializerTrackedObject.ApplyChangesMethod
Determines the type of property update that will be performed.