ドキュメント

Unity Engine

Unity Engine

LocalizeGameObjectEvent

Component that resolves a localized prefab and forwards it through a UnityEvent whenever the value or the selected locale changes.
読み終わるまでの所要時間 7 分最終更新 1ヶ月前

Definition

[AddComponentMenu("Localization/Localize Game Object Event")]public class LocalizeGameObjectEvent : LocalizeAssetEvent<GameObject>

Remarks

This is the GameObject specialization of LocalizeAssetEvent<TObject>. Add it to a GameObject, assign its LocalizeAssetEvent<TObject>.AssetReference in the Inspector, then connect LocalizeAssetEvent<TObject>.OnUpdateAsset to code that swaps an instantiated prefab, for content that differs per locale in more than text, such as signage models or layout variants.
Replace the spawned instance when the resolved prefab changes.

Examples

using Unity.Localization.Components;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizeGameObjectEventBindingExample : MonoBehaviour { public LocalizeGameObjectEvent localize; GameObject m_Instance; void OnEnable() => localize.OnUpdateAsset.AddListener(OnUpdate); void OnDisable() => localize.OnUpdateAsset.RemoveListener(OnUpdate); void OnUpdate(GameObject prefab) { if (m_Instance != null) Destroy(m_Instance); m_Instance = prefab != null ? Instantiate(prefab, transform) : null; } }}

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.