Skip to content

Instantly share code, notes, and snippets.

@karljj1
Created July 18, 2023 09:56
Show Gist options
  • Save karljj1/fda3c7f128a72fb3aeea2984b0619188 to your computer and use it in GitHub Desktop.
Save karljj1/fda3c7f128a72fb3aeea2984b0619188 to your computer and use it in GitHub Desktop.
Mark LocalizeStringEvent entry as Smart
using UnityEditor;
using UnityEditor.Localization;
using UnityEngine.Localization.Components;
public class MarkSmart
{
[MenuItem("CONTEXT/Component/Mark Smart", true)]
public static bool MarkEntrySmartValidate(MenuCommand menuCommand) => menuCommand.context is LocalizeStringEvent;
[MenuItem("CONTEXT/Component/Mark Smart", false)]
public static void MarkEntrySmart(MenuCommand menuCommand)
{
var loc = menuCommand.context as LocalizeStringEvent;
var collection = LocalizationEditorSettings.GetStringTableCollection(loc.StringReference.TableReference);
foreach (var table in collection.StringTables)
{
var entry = table.GetEntryFromReference(loc.StringReference.TableEntryReference);
entry.IsSmart = true;
EditorUtility.SetDirty(table);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment