How can I read metadata at runtime?
I made a custom metadata class for holding the Rect transform size of my text and need a way to access the metadata so I can use it after a string is set, but I can’t seem to figure out how
public class UpdateLocalizedString : MonoBehaviour
{
public LocalizeStringEvent stringToUpdate;
public LocalizedString[] strings;
public void UpdateReference(int i)
{
stringToUpdate.StringReference = strings[i];
var currentLoadingOperation = strings[i].CurrentLoadingOperation;
if (currentLoadingOperation.HasValue)
{
currentLoadingOperation.Value.Completed += ValueOnCompleted;
}
}
private void ValueOnCompleted(AsyncOperationHandle<LocalizedDatabase<StringTable, StringTableEntry>.TableEntryResult> handle)
{
var rectData = handle.Result.Entry.GetMetadata<RectSizeMetaData>();
Debug.LogWarning(rectData.Size);
}
}
Is this correct?
I suppose i need to do an isDone check tho because completed probably wont fire if its already loaded into memory by chance i suppose